Load PNG !?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Locked
ShUr1k3n
Posts: 42
Joined: Sun Oct 16, 2005 9:04 pm

Load PNG !?

Post by ShUr1k3n »

Guys, how can i display a PNG image to the screen !?

I convert the PNG file to C ( using png2c.C )...
I tried with a BitMap ( BMP ) file and it works fine, but with the PNG i just get some "mixed" pixels... =S

Can u plz tell me how can i make this work fine ?!

This is the code i use:

Code: Select all


 void pgBitBlt(unsigned long x,unsigned long y,unsigned long w,unsigned long h,unsigned long mag,const unsigned short *d)
 {
 	unsigned char *vptr0;		//pointer to vram
 	unsigned char *vptr;		//pointer to vram
 	unsigned long xx,yy,mx,my;
 	const unsigned short *dd;
 	
 	vptr0=pgGetVramAddr(x,y);
 	for &#40;yy=0; yy < h; yy ++&#41; &#123;
 		for &#40;my=0; my < mag; my ++&#41; &#123;
 			vptr=vptr0;
 			dd=d;
 			for &#40;xx=0; xx < w; xx ++&#41; &#123;
 				for &#40;mx=0; mx < mag; mx ++&#41; &#123;
 		    		if&#40;*dd != 0xFFFF&#41;&#123; *&#40;unsigned short *&#41;vptr=*dd;&#125;
 					vptr += PIXELSIZE*2;
 				&#125;
 				dd ++;
 			&#125;
 			vptr0 += LINESIZE*2;
 		&#125;
 		d += w;
 	&#125;
 	
 &#125;
and can i plz tell me too whats the meaning of this "unsigned long mag"...

Thks,

ShUr1k3n.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Please search the forums, someone asks how to load a PNG at least once a week. Locked for redundancy.
Locked