Skip to main content
gamedev.net
🔒 Locked

Surface data - X offset problem?

Started by Painless May 17, 2003 at 7:49 PM 0 replies 250+ views
Original Post
Painless
Painless
Well, I have no idea what I should search for with this problem, so I'll just post it here. My problem is that when I lock a directx surface and try to manipulate the data, to get a "setpixel" sort of function to work, I need to "rotate" (add and modulo) the x-value by some value that seems pretty much random (it's 6 pixels for a 256x256 R5G6B5 surface; for other sizes it's different). Unfortunately, I don't have the exact code here, but it's something like this:
void set_buffer( unsigned short *buffer, int buffer_pitch, int x, int y, float f )
{
  unsigned char c = ( unsigned char )( f * 256.0F );
  buffer[ y * buffer_pitch + x ] = ( ( c >> 1 ) << 11 ) + ( c << 5 ) + ( c >> 1 );
}
  
But, as I said, I have to do some tweaking with "x", otherwise the wrong pixel gets written. Anyone have an idea what might be wrong? Forgot to mention.. I am using D3DXSaveSurfaceToFile( blah ) to save the surface, and that's the only way I have to inspect the surface. [edited by - Painless on May 17, 2003 8:51:32 PM]
Painless
Painless
Well, I found the problem.. it''s called MS Paint. *grumble*

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.