绘制成缩放的CGContext会产生全白图像

时间:2018-01-07 02:04:23

标签: ios cocoa-touch core-graphics

如果我将图像绘制到CGContext中,当我稍后从中创建图像时,它会按预期工作。但是当我想通过将X轴缩放-1来镜像这个图像时,产生图像的相同代码会产生全白图像 - 即。不起作用。我错过了什么?

<?xml version="1.0" encoding="utf-8"?> <packages>   
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="25.4.0.2" targetFramework="monoandroid71" />   
<package id="Xamarin.Android.Support.Annotations" version="25.4.0.2" targetFramework="monoandroid71" />   
<package id="Xamarin.Android.Support.Compat" version="25.4.0.2" targetFramework="monoandroid71" />   
<package id="Xamarin.Android.Support.Core.UI" version="25.4.0.2" targetFramework="monoandroid71" />   
<package id="Xamarin.Android.Support.Core.Utils" version="25.4.0.2" targetFramework="monoandroid71" />   
<package id="Xamarin.Android.Support.Design" version="25.4.0.2" targetFramework="monoandroid71" />  
<package id="Xamarin.Android.Support.Fragment" version="25.4.0.2" targetFramework="monoandroid71" />   
<package id="Xamarin.Android.Support.Media.Compat" version="25.4.0.2" targetFramework="monoandroid71" />   
<package id="Xamarin.Android.Support.Transition" version="25.4.0.1" targetFramework="monoandroid71" />   
<package id="Xamarin.Android.Support.v4" version="25.4.0.2" targetFramework="monoandroid71" />   
<package id="Xamarin.Android.Support.v7.AppCompat" version="25.4.0.2" targetFramework="monoandroid71" />   
<package id="Xamarin.Android.Support.v7.CardView" version="25.4.0.2" targetFramework="monoandroid71" />   
<package id="Xamarin.Android.Support.v7.MediaRouter" version="25.4.0.2" targetFramework="monoandroid71" />   
<package id="Xamarin.Android.Support.v7.Palette" version="25.4.0.2" targetFramework="monoandroid71" />   
<package id="Xamarin.Android.Support.v7.RecyclerView" version="25.4.0.2" targetFramework="monoandroid71" />   
<package id="Xamarin.Android.Support.Vector.Drawable" version="25.4.0.2" targetFramework="monoandroid71" />  
<package id="Xamarin.Forms" version="2.4.0.280" targetFramework="monoandroid71" /> </packages>

1 个答案:

答案 0 :(得分:1)

您已经在Y轴上镜像了图像。所以点(1,0)现在是(-1,0)。这意味着一切都(几乎可以肯定)在X平面的负半部分之外绘制。

如果您需要&#34;右边缘&#34>,您还需要按屏幕宽度翻译上下文。为零。类似的东西:

context.translateBy(x: bounds.width, y:0)

(未测试的)