Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Syntax

16bit, and 24 bit Put Pixel? Need Some Help.

This topic is 7131 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, I am writing a program that needs to use a put pixel routine, I would like the program to be in 16 bit and 24 bit color modes..the things is i am a bit unsure on how to do this in DirectDraw, The program is currently using a windows GDI window but I want that to change, I am not doing anything that requires blting, so I need help specifically on Put Pixel routines for 16/24bit on DD .. Thanx for any help guys.. -Lucas

Share this post


Link to post
Share on other sites
Advertisement
Are you looking for info about DD in general plus putting a pixel, or do you already have an understanding about surfaces/locking/etc and just need a pixel function?

aig

Share this post


Link to post
Share on other sites
I am no DD guru, but i do understand the concept of DD surfaces..I just need a routine to plot a pixel on a 16bit and 24bit surface..
-Lucas

Share this post


Link to post
Share on other sites
Once you have a surface locked, it''s not hard because you can access the video mem linearly.

Thus, plotting a 16 bit pixel becomes:



inline Plot16(int x, int y, unsigned short color, unsigned short *buffer, int pitch)
{
buffer[x + y*(pitch/2)] = color;
}



Plotting a 24-bit pixel is a little more complicated, but not much:



inline Plot24(int x, int y, unsigned char red, unsigned char green, unsigned char blue, unsigned char *buffer, int pitch)
{
int offset = x + y*(pitch/3);
buffer[offset] = blue;
buffer[offset+1] = green;
buffer[offset+2] = red;
}



To build the colors before calling the 16 bit function, you would do something like:



#define RGB16BIT565(r,g,b) ((b%32) + ((g%64)<<6) + ((r%32)<<11)
unsigned short color16 = RGB16BIT565(red, green, blue);



You would then call them like:



unsigned short color16 = RGB16BIT565(red, green, blue);
Plot16(x, y, color16, (unsigned short *)ddsd.lpSurface, ddsd.lPitch);
Plot24(x, y, red, green, blue, (unsigned short *)ddsd.lpSurface, ddsd.lPitch);



aig

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!