2

我有一些代码在 iO 中运行良好,但在 Android 上会导致图像完全混乱。我找到了部分解决方法(不调用某些代码),但它暗示了一些严重错误:

// some bitmap object buffer for mainthread only
R.BitmapRef := FPersistentBitmapBuffer;

// this TImage now contains the original wrongly sized bitmap
ImageBackground.Bitmap.Assign(R.BitmapRef); 

// calculated somewhere
TmpNewWidth := 500; 
TmpNewHeight := 500;

// draw the bitmap resized to wanted size
R.BitmapRef.Width := Round(TmpNewWidth);
R.BitmapRef.Height := Round(TmpNewHeight);
R.BitmapRef.Canvas.BeginScene();
R.BitmapRef.Canvas.DrawBitmap(ImageBackground.Bitmap, RectF(0,0,ImageBackground.Bitmap.Width,ImageBackground.Bitmap.Height), RectF(0,0,TmpNewWidth,TmpNewHeight), 1);
R.BitmapRef.Canvas.EndScene();

// assign it back to the image 
ImageBackground.Bitmap.Assign(R.BitmapRef);

// THIS code causes the image shown in TImageBackground to look completely garbled ... which would indicate something is shareing memory/reference somewhere somehow... There is more odd behavior like debugger unhooking (it seems) if mouse in Delphi debugger hovers over ImageBackground.Bitmap - no error is reported
R.BitmapRef.Clear(TAlphaColorRec.White); 

可以看出,这是把它搞砸的最后一行。在某些测试中,删除线似乎就足够了,但在其他测试中则不然。这是我对问题的最佳线索/描述/示例。

这是一个乱码图像的示例。由于每次运行应用程序时它们看起来都是一样的乱码,我怀疑它一定与图像有某种关系,但没有任何视觉相似性。

在此处输入图像描述 我的问题是有什么问题?我正在测试 Delphi XE7 试用版,所以我无法访问源代码。它在使用 XE4 和 XE7 的 iOS 上完美运行,但在 Android 上却发生了一些事情。我认为它可能是一些共享参考的位图数据......有没有人对如何测试这个理论/可能的解决方法有任何想法?

4

1 回答 1

2

这看起来显然是错误的。我建议您在http://quality.embarcadero.com填写错误报告

尝试使用 CopyFromBitmap 而不是“分配”。这将创建图像的唯一副本。如果您调用MyBitmap.Map(TMapAccess.Write, MyBitmapData);后跟 ,您还将获得一个新的独特图像MyBitmap.UnMap(MyBitmapData);

于 2014-12-27T11:44:07.600 回答