Draw TBitmap in DelphiX
Hello
What''s the best (fastest) way to draw a TBitmap (created in runtime) on a surface?
The Tbitmap have a color that should be transparent.
If I use .Draw(X,Y,TBitmap), I don''t get the transparency.
If I use .BrushCopy(...), everything work but it''s very slow.
Thanks
/ Tommy
As long as you do not create a DirectDrawSurface for your Bitmap, every attempt to draw a bitmap on a Surface will work like this:
1. Lock the surface
2. Get the Surface''s DeviceContext
3. Perform a BitBlt
4. Unlock the surface
This is obviously very slow and it does not support transparency as long as you use a complex masking system that would slow everything down even more.
So you now have to possibilities
1. Add your bitmap to the DXImageList and draw it from there (this way, your bitmap will have its own DirectDrawSurface)
2. Create an external DirectDrawSurface, draw the bitmap on it and then FastBlt this surface onto the DXDraw surface. This solution is a lot more complicated and not very pretty either.
1. Lock the surface
2. Get the Surface''s DeviceContext
3. Perform a BitBlt
4. Unlock the surface
This is obviously very slow and it does not support transparency as long as you use a complex masking system that would slow everything down even more.
So you now have to possibilities
1. Add your bitmap to the DXImageList and draw it from there (this way, your bitmap will have its own DirectDrawSurface)
2. Create an external DirectDrawSurface, draw the bitmap on it and then FastBlt this surface onto the DXDraw surface. This solution is a lot more complicated and not very pretty either.
Maybe instead of creating a TBitmap at runtime, you should create a TDirectDrawSurface.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement