1

我的问题有点奇怪!!我将为 windows phone 8 创建一个带有可写位图的日历图块。所以我使用这个字符“”。我正在使用下面的代码,一切正常,正如我在模拟器上所期望的那样。但是当我在真实设备上测试我的应用程序时,日历字符会出现不同

private void RenderText9()
    {
        int width = 159;
        int height = 159;
        string imagename = "SmallBackground";

        WriteableBitmap b = new WriteableBitmap(width, height);

        var canvas = new Grid();
        canvas.Width = b.PixelWidth;
        canvas.Height = b.PixelHeight;

        var background = new Canvas();
        background.Height = b.PixelHeight;
        background.Width = b.PixelWidth;

        SolidColorBrush backColor = new SolidColorBrush((Color)Application.Current.Resources["PhoneAccentColor"]);
        background.Background = backColor;

        var textBlock = new TextBlock();
        textBlock.Text = "25";
        textBlock.TextAlignment = TextAlignment.Center;
        textBlock.Margin = new Thickness(0, 72, 0, 0);
        textBlock.Width = 159;
        textBlock.TextWrapping = TextWrapping.Wrap;
        textBlock.Foreground = new SolidColorBrush(Colors.White);
        textBlock.FontSize = 35;

        var textBlock2 = new TextBlock();
        textBlock2.Text = "";
        textBlock2.TextAlignment = TextAlignment.Center;
        textBlock2.Margin = new Thickness(0, 40, 0, 0);
        textBlock2.Width = 159;
        textBlock2.TextWrapping = TextWrapping.Wrap;
        textBlock2.Foreground = new SolidColorBrush(Colors.White); //color of the text on the Tile    
        textBlock2.FontSize = 75;

        canvas.Children.Add(textBlock);
        canvas.Children.Add(textBlock2);

        b.Render(background, null);
        b.Render(canvas, null);
        b.Invalidate(); //Draw bitmap

        //Save bitmap as jpeg file in Isolated Storage    
        using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
        {
            using (IsolatedStorageFileStream imageStream = new IsolatedStorageFileStream("/Shared/ShellContent/" + imagename + ".jpg", System.IO.FileMode.Create, isf))
            {
                b.SaveJpeg(imageStream, b.PixelWidth, b.PixelHeight, 0, 100);
            }
        }
    }

这是模拟器和真实设备上的瓷砖(注意差异)。有人知道任何解决方案吗???不明白原因!! 在此处输入图像描述

4

0 回答 0