Memory buffer to Surface?
Let''s say I load a bitmap file and read the data into "Buffer". Then let''s say I have a DirectDrawSurface, "mySurface".
Could I blit the buffer onto the surface directly? What about using memcry()? Or what do I need to do?
No, DirectDraw blit only works between surfaces. For a GDI blit, you would need to select your bitmap into a device context, and then blit to a DC taken from the surface.
Alternatively you could lock your surface and write the pixels directly.
Alternatively you could lock your surface and write the pixels directly.
with dx7 when you lock a surface you can get a pointer to the linear frame buffer. As long as the surface & bmp formats are exactly the same, you could pass that pointer to the bmp loader and load the bmp directly to the surface.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
quote:
with dx7 when you lock a surface you can get a pointer to the linear frame buffer. As long as the surface & bmp formats are exactly the same, you could pass that pointer to the bmp loader and load the bmp directly to the surface.
In the unlikely event that the pixel formats are the same, you still cannot guarantee that the surface has the same pitch as the bitmap, so I would avoid using this method.
TwoFlower, what method do you then recommend?
Oh by the way, how do you convert bitmaps between different bpp(8, 16, 24, 32, etc.)?
Oh by the way, how do you convert bitmaps between different bpp(8, 16, 24, 32, etc.)?
If you''re using DirectX 7, then use the utility library texture functions to load your bitmap.
If not, use LoadImage and then blit from a DC to the DC of the surface.
Both methods will do the conversion for you (as well as scaling - The former will also do filtering and mipmaps if you ask nicely)
If not, use LoadImage and then blit from a DC to the DC of the surface.
Both methods will do the conversion for you (as well as scaling - The former will also do filtering and mipmaps if you ask nicely)
Well actually, I''m not loading the bitmap from a ".bmp" file. I''ve packed all my ".bmp" files into a custom file I''ve created.
IIRC the utiltility library functions will accept bitmaps in memory as well as from files, other than that, you can still create a DIB section and blit it to the surface using GDI.
November 20, 2000 08:50 PM
Just lock the surface and memcpy each line from your buffer into the surface. Its not as nice as doing one memcpy for the whole thing but this way you can adjust for different surface pitches.
For converting between formats youre gonna have to do each pixel individually, well you could use mmx and do packed operations to process a few pixels at once but why waste the time coding it this is only going to be done at load time.
Josh
For converting between formats youre gonna have to do each pixel individually, well you could use mmx and do packed operations to process a few pixels at once but why waste the time coding it this is only going to be done at load time.
Josh
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement