TBitmap在Android恢复应用程序上消失
我尝试在Android中使用位图,但不幸的是我遇到了一些问题 我创建了一个内部定制的TComponent,它使用绘制事件绘制的TBitmap:TBitmap在Android恢复应用程序上消失,android,delphi,bitmap,paint,Android,Delphi,Bitmap,Paint,我尝试在Android中使用位图,但不幸的是我遇到了一些问题 我创建了一个内部定制的TComponent,它使用绘制事件绘制的TBitmap: TMyThumbnail = class( TControl ) private FBitmap: TBitmap; protected procedure Paint; override; public constructor Create( AOwner: TComponent ); override;
TMyThumbnail = class( TControl )
private
FBitmap: TBitmap;
protected
procedure Paint; override;
public
constructor Create( AOwner: TComponent ); override;
destructor Destroy; override;
end;
constructor TMyThumbnail.Create( AOwner: TComponent );
begin
inherited;
FBitmap := TBitmap.Create;
end;
destructor TMyThumbnail.Destroy;
begin
FBitmap.Free;
inherited;
end;
procedure TMyThumbnail.Paint;
begin
Canvas.BeginScene;
try
// * On Resume App the FBitmap is not Empty!
if ( not FBitmap.IsEmpty ) then
// ** So FBitmap is not empty and Width/Height are correct but is drawn as empty or nothing happens !
Canvas.DrawBitmap ( FBitmap, TRectF.( 0, 0, FBitmap.Width, FBitmap.Height ), ClientRect, 1 );
finally
Canvas.EndScene;
end;
end;
分配或加载位图时,一切正常进行,组件正确绘制位图
当我从应用程序中出去并呼叫或打开另一个应用程序/我的外部应用程序时,就会出现问题
在应用程序中返回位图不是空的,并且具有正确的大小,只是调用时未绘制该位图:
Canvas.DrawBitmap (FBitmap, BitmapRect, ClientRect, 1 );
有什么建议吗?
谢谢。我想我知道在Android中使用Assign确实不会分配物理内存,而只分配引用。相反,使用CopyFromBitmap函数显然是可行的。CopyFromBitmap();