   Problem: Distorted 8-bit gfx in DirectDraw Surface
  Hello everybody,I wrote a small app which should load a bitmap (8 bit)in an array an than copy this array in a Direct Draw Surface.This works correct with small graphics like 20x20 but when I use bigger (100x100) for example, the graphics are displayed distorted. It seems that the pixel in the lower left corner is correct, and the others are pushed 1 pixel to the right each line. I wrote this in according to the examples of "tricks of the windows game programming gurus" by andre la mothe, and here is the routine to copy the bimap data to the surface:lpitch = (int)ddsd.lPitch;UCHAR *source=bitmap.buffer;UCHAR *dest=(UCHAR *)ddsd.lpSurface;  for(int i=0;i < ddsd.dwHeight;i++)  {    memcpy(dest, source, bitmap.bitmapinfoheader.biWidth);    dest   += lpitch;    source += bitmap.bitmapinfoheader.biWidth;    } // end for index_yI also tried another copy algorithm, but it looks the same...I hope you can help me... 
  well, try this:int source_width;source_width = ( bitmapinfoheader.biWidth > ddsd.lPitch ) ? ddsd.lPitch : bitmapinfoheader.biWidth;instead of using bitmap.bitmapinfoheader.biWidth directly like that.   [edited by - alnite on February 11, 2004 5:18:19 PM];  Thanks for your reply,alnite, but this wasn not the problem... The picture looks even more distorted Any other suggests ? ;  well... you are stepping through the destination bitmap based on the pitch.. but the source bitmap based on the width... why don''t you step through each based on it''s respective pitch? I think if the width is a power of two, the pitch is necessarily the width (not 100% on that) so maybe try a bitmap that is a power of 2 wide, and see if it''s fixed.. then you should be able to confirm if it is a pitch/width issue. 