Loading Bitmaps

Hello all…

Im trying to load a number of bimap images(640x480) into small viewports…
Problem is,this process takes a lot of time…about 1 sec to load 15 bitmap images!!
isnt it too slow??

Is there a way to make it fast??? Im using single buffer mode…
Please help.

Thanks in advance…

18 MB per second is not that slow when loaded from disk.

Yes there may be ways to make it faster. But you don’t say which ones you currently use, so it will be hard to propose better ways.

I had posted regarding loading bitmaps earlier.After taking your valuable suggestions ,now its working :slight_smile:

So now im using that function to load several bitmaps onto the screen…These are somehing like my menu items…

here is the code im usig to load bitmaps…

/Info about the Bitmap image/
typedef struct {
unsigned short type;
unsigned long size;
unsigned short reserved1;
unsigned short reserved2;
unsigned long offsetbits;
} BITMAPFILEHEADER12;

typedef struct {
unsigned long size;
unsigned long width;
unsigned long height;
unsigned short planes;
unsigned short bitcount;
unsigned long compression;
unsigned long sizeimage;
long xpelspermeter;
long ypelspermeter;
unsigned long colorsused;
unsigned long colorsimportant;
} BITMAPINFOHEADER12;

typedef struct {
unsigned char blue;
unsigned char green;
unsigned char red;
} SINGLE_PIXEL12;

void Open_Bitmap(char *name)
{
FILE *fp;unsigned char p;
int x=0,y=0,c=0;
float r,g,b;

BITMAPINFOHEADER12 bitm;
BITMAPFILEHEADER12 bitmp;

fp = fopen(name,"rb");

fread(&bitmp,14,1,fp);
fread(&bitm,40,1,fp);


gluOrtho2D(0.0,640.0,0.0,480.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();	

glPointSize(2);
glBegin(GL_POINTS);
while(!feof(fp))
{
	fread(&p,1,1,fp);
	b = p/255.0;
	fread(&p,1,1,fp);
	g = p/255.0;
	fread(&p,1,1,fp);
	r = p/255.0;
	

	glColor3f(r,g,b);
	glVertex2i(x++,y);

	if(x == (signed)bitm.width)
	{	
		x = 0;
		y++;
	}
	
}
glEnd();
glFlush();
fclose(fp);

}

So by using the above function im loading those bitmaps…Can i make it fast??

Im using single buffer mode…

I don’t think there is a problem with that, i mean, it not slow, if it load 15 bitmap images in 1 sec

Mukund, your problem is that you do both the image loading and image draw in a single step.
The correct way is to load all needed images from disk at program startup, then draw each image only when needed.
Drawing each point by hand with immediate function call is slow too, you can use glDrawPixels to draw a whole array of pixels in a single call :
http://www.opengl.org/sdk/docs/man/xhtml/glDrawPixels.xml
If you need scaling/rotating, even better is to draw a textured quad. Search for texturing tutorials.

And, by the way, single buffer mode is mostly deprecated, only double buffered mode should be used nowadays.

Thank you Zbuffer…I got your idea…So this is something like drawing just a single Bitmap!
Cool!

Thank you…One more thing…This is not totaly relavant to the curent topic…But im just curious to know…

I was wondering how the high end graphic based games do the graphic rendering…I mean there is so much of data being displayed…How exactly do they make it so fast??

For high performance rendering, it is important to take advantage of all the hardware capabilities : GPU, CPU, various bus, RAM, disk, …
While the GPU renders geometry and textures from its Video ram, the CPU streams new objetcs data to vram in parallel (asynchronously), so later the GPU can render these new objetcs.
VBO and PBO help a lot for this kind of stuff.
http://www.songho.ca/opengl/gl_vbo.html
http://www.songho.ca/opengl/gl_pbo.html
With only a few GL commands (not counting the set up, only the calls made to render a frame), a lot of things can be rendered.