on delphi/android how to draw a TbitmapSurface on a Canvas?

后端 未结 2 678
既然无缘
既然无缘 2021-01-28 08:36

Under delphi (and under firemonkey/android), What is the most fastest way to draw on a Tcanvas a TbitmapSurface ?

I try to use TTexture like MyTexture.Assign(aBitmapSur

2条回答
  •  无人及你
    2021-01-28 09:16

    I do not use/code for Android so read with extreme prejudice. As Delphi uses VCL so I stick to it. If Delphi under Android does not then you can ignore this answer.

    It looks like it is similar problem to Windows when accessing any OS visual stuff (does not matter if by GDI or WinAPI) from outside main thread will invalidate the OS API making weird things latter like random crashes, wrong rendering, etc. Another reason can be the use of GPU related calls which are usually bound to process/thread and device context. So to make it thread safe you could have to create shared context if possible if not you need to stick to main thread.

    By Assign you are creating new image and copy the old to it that takes time comparable to drawing itself not to mention on devices with slow memory it can really slow down the whole thing considerably a lot more.

    If you are dealing with VCL graphic components then try to use Draw directly:

    • blablabla->Canvas->Draw(x,y,aBitmapSurface);

    if blablabla and aBitmapSurface are valid gfx components then it should work. As I mentioned not sure if this is present also in Android. The x,y is the position where you want to draw the aBitmapSurface. There is also StretchDraw if you need to rescale but that is a bit slower.

    See Display an array of color in C sections GDI and GDI Bitmap for some ideas under VCL

提交回复
热议问题