Hello, is there any way to draw TBitmap type from Delphi in CGE? I know there is TDrawableImage which takes TCastleImage, where currently I am doing conversion, but manually pixel by pixel and thats quite slow. I cant load the picture from disk, as its created during runtime in memory. So is there any method to draw default bitmap type in CGE, or any quicker conversion variant (as I have to manually update it on change multiple times during runtime, meaning to undergo slow conversion again)? I would try to copy internal memory structure to RawPixels with bitmap scanline, but as pixels in TRGBAlphaImage are of type TVector4Byte, internal memory representation would not be compatible either way I guess. Thanks.
We don’t support directly using Delphi’s
TBitmap. As you mention, we have our own
TDrawableImage (which can be drawn) and
TCastleImage (which has
RawPixels and can be used as initial contents of
Indeed the way to go is to copy over between
TBitmap.ScanLine and our
RawPixels, and account for differences. You will likely need to swap RGB<->BGR indeed. Some code in CGE already does this when converting with other libraries, like
src/images/castleimages_vcl_imaging.inc (uses Delphi
src/images/castleimages_vampyre_imaging.inc (loads using Vampyre Imaging; I see we actually use
SwapChannels from Vampyre in this case).
So, we don’t have a better approach, but you can manually copy (and eventually RGB<->BGR swap) and it may be fast enough for some purposes.
An alternative approach may be to not use Delphi’s
TBitmap and do 100% image drawing using CGE I know it depends on the situation though.
Well as I do extend current application with CGE as one of the options to display, I need to rely on using constructs I get, in this case I do get TBitmap instance and that I need to draw. But I used LoadEncodedImage method where I put bitmap into stream and it works a bit faster so for now it will do, thanks.