yourbuffer[x + y*(lpitch >> 1)] = pixel or whatever.
Let me know if that worked. Good luck, friz
------------------
Still Learning...
[This message has been edited by frizb (edited November 19, 1999).]
yourbuffer[x + y*(lpitch >> 1)] = pixel or whatever.
Let me know if that worked. Good luck, friz
------------------
Still Learning...
[This message has been edited by frizb (edited November 19, 1999).]
Okay, here is what I think you are doing, or at least a small part of it.
1) You have got a directdraw surface with the height and width of the image you are want to load.
2) You open the image.
3) Lock the surface, read in the BGR format pixels into unsigned char. Convert it to a 16 bit (either 1555 or 565....the one showed is for 1555)
unsigned short color = (unsigned short)( ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3) );
And then you put this value onto the directrawsurface.
Shouldn't be too difficult.
------------------
Dance with me......
so....add the lPitch - DDSURFWidth to the surfacepointer.....
And keep in mind that a 24 bits bitmap is saved in reverse order (bottom to top) so you need to subtract 2 times the width each time.
------------------
Dance with me......
------------------
VisualLR
visuallr@netscape.net
http://www.geocities.com/SiliconValley/6276
Bitmap image;
image.LoadBitmap("24BitGraphic.bmp");
so now the BMP is loaded and converted to a 16bit BMP stored in image.buffer
so now I lock the back surface (Im not using offsurfaces now, cause Im only interested in displaying the bitmap correctly at the time, I'll make it work better once it's actually working), after I lock the back surface I do something like this:
for (int i=0; i < (2*image.Height)-1; i++)
{
memcpy(SurfacePtr, image.buffer, image.Width);
SurfacePtr += 640;
image.buffer += image.Width;
}
and what that does is display HALF of the bitmap where it's supposed to be, then a gap between that and the other half...
However, if I do this:
for (int i=0; i < (2*image.Height)-1; i++)
{
memcpy(SurfacePtr, image.buffer, image.Width*2);
SurfacePtr += 640;
image.buffer += image.Width*2;
}
it displays the bitmap correctly on the top left corner, BUT, it displays a second copy of the bitmap after the gap, only the second copy of the bitmap is distorted (second half is drawn first, first half last)..
I know the bitmap loading/conversion part is working, cause if I write the converted bitmap to a file, it'll work fine when I open it with PSP. So Im thinking my problem is in the actual blitting of the image (the colors work fine, btw).
Thanks!
------------------
VisualLR
visuallr@netscape.net
http://www.geocities.com/SiliconValley/6276