Hi,
Just a little file to load and see a bmp.
I don't undestand why it doesn't work.
The bmp is 16bits, 320*240
but on gp32 it's very strange. ( big pixel, not good color )
Just a little file to load and see a bmp.
I don't undestand why it doesn't work.
The bmp is 16bits, 320*240
but on gp32 it's very strange. ( big pixel, not good color )
Code:
#include "gpdef.h"
#include "gpstdlib.h"
#include "gpgraphic.h"
#include "gpmain.h"
#include "gpfont.h"
#include "gpmm.h"
GPDRAWSURFACE gpDraw[2];
int nflip = 1;
uchar bitmap[320*240];
char load_bmp(char file_name[256], unsigned char * ptr);
void GpMain(void *arg)
{
unsigned int i;
for(i = 0; i < 2; ++i) GpLcdSurfaceGet(&gpDraw[i], i);
GpSurfaceSet(&gpDraw[0]);
GpFatInit();
load_bmp("gp:\\gpmm\\pic.bmp", bitmap);
for(;;)
{
GpBitBlt16(NULL, &gpDraw[nflip], 0, 0, 320, 240, (uchar *)bitmap, 0, 0, 320, 240);
GpSurfaceFlip(&gpDraw[nflip++]);
nflip &= 0x01;
}
}
char load_bmp(char file_name[256], unsigned char * ptr)
{
int heigh=240;
int width=320;
F_HANDLE img;
long k2;
ulong k;
int x, y;
unsigned char temp[320*240];
if(GpFileOpen(file_name, OPEN_R, &img) == SM_OK)
{
GpFileSeek(img, FROM_BEGIN, 54, &k2); // 54 = 16 bits
GpFileRead(img, &temp, width*heigh, &k);
GpFileClose(img);
for(y=0; y<heigh; y++)
for(x=0; x<width; x++)
*(ptr+x*heigh+y)=temp[y*width+x];
return 1;
}
else return 0;
}