Hi all,
I am using LOCK SURFACE extension.I want to draw an image as it is to a specified position.But it is streached i dont know why??
The following is the code for reading pixel data from my bmp image.
Here name is my bmp image name
Code :
#define GET_INT(/*KDchar* */ p) (((((KDint) p[3]) & 0xff) << 24) + \
      ( (((KDint) p[2]) & 0xff) << 16) + \
      ( (((KDint) p[1]) & 0xff) <<  8) + \
      (((KDint) p[0]) & 0xff))
 
KDFile* fin = kdFopen(name, "rb");
 
KDchar fileheader[54];
KDchar *header = fileheader;
kdFread(header, 1, 54, fin);
 
header += 10;
KDint offset = GET_INT(header);
header += 8;
width = GET_INT(header);
header += 4;
height = GET_INT(header);
kdFseek(fin, offset, KD_SEEK_SET);
KDint32 res = 3 * width * height;
rgbaBuf = (KDchar *) kdMalloc(res);
imageDataSize = res;
kdFread(rgbaBuf, res, 1, fin);
 
kdFclose(fin);

For drawing image i am using following code: Here ptr is client memory pointer
Code :
KDint x , y;
x = imageDataSize/height;
for (y = 0; y < height; y++)
{
   kdMemcpy(ptr, rgbaBuf,x);
   rgbaBuf += x;
   ptr += stride;
}