GP32 Displaying Pic


Tealion

Still Fresh
Joined
Mar 15, 2004
Messages
33
Age
37
Location
Exeter Devon UK
Website
Visit site
OK, I know a similar question to this has just been asked but I cannot get the GP32 to display an image :( with Mr.Mirkos SDK.

I converted my picture to an array with the provided program and then used the following code:

Code:
#include <gp32.h>
#include "data.c"


unsigned short *framebuffer;

int main(void)
{
	int i;
	framebuffer = (unsigned short*) FRAMEBUFFER;

	gp_ButtonInit();
	gp_SetScreen(framebuffer, 16);

	for(i=0; i < 320*240; i++)
  framebuffer[i] = data[i];

	while(1)
  if(gp_ButtonResult() &BA) gp_Reset();

	return 0;

}

and for some reason the picture is not displaying :( i just get a load of junk on the screen. What am i doing wrong? (its probably something stupid, it might be the convertor???? !)

Thankyou

Teal
 
Tealion posted on Mar 15 2004 at 09:26 PM said:
OK, I know a similar question to this has just been asked but I cannot get the GP32 to display an image :( with Mr.Mirkos SDK.

I converted my picture to an array with the provided program and then used the following code:

and for some reason the picture is not displaying :( i just get a load of junk on the screen. What am i doing wrong? (its probably something stupid, it might be the convertor????  !)

Thankyou

Teal
looks 100% perfect,
how did you convert the data ?

please post the first line of
data.c

Please keep in mind that the file2array programm stores the data in chars,
and the framebuffer is 2Byte long.

So you need to cast the data in data.c

do this:

Code:
#include <gp32.h>
#include "data.c"

unsigned short *background;
unsigned short *framebuffer;

int main(void)
{
	int i;
	framebuffer = (unsigned short*) FRAMEBUFFER;
	background  = (unsigned short*) data;

	gp_ButtonInit();
	gp_SetScreen(framebuffer, 16);

	for(i=0; i < 320*240; i++)
  framebuffer[i] = background[i];

	while(1)
  if(gp_ButtonResult() &BA) gp_Reset();

	return 0;

}

now the data is cased from 8 bit to 16 bit.

it should work now.


ALSO, keep in mind that the gp32 screen is 240x320, and if your
bitmap is in 320x240 format, you should better use the gp_SetPixel16
function to set a point.

int i,x,y;
i=0;
for (y=0;y<240;y++)
for (x=0;x<320;x++) gp_SetPixel16(x,y,background[i++];
 
Last edited by a moderator:
gp_SetView(framebuffer);

Nope that didn't work :(

I made the image in the Gimp on linux and then set the size to 240x320. I then saved it as a bitmap and typed the following to convert the file.

Code:
convert mypic.bmp >> picture.c

Maybe the save settings are the problem??

I then used this code :
Code:
#include "gp32.h"
#include "picture.c"

unsigned short *framebuffer;
unsigned short *background;

int main(void)
{
	int x;

	framebuffer = (unsigned short*) FRAMEBUFFER;
	background = (unsigned short*) data;

	gp_ButtonInit();
	gp_SetScreen(framebuffer, 16);	
	gp_SetCpuSpeed(66);

        //copy pic data
	for(x=0; x < 320*240; x++)
  framebuffer[x] = background[x];

	while(1)
  if( gp_ButtonResult() &BA)
  	gp_Reset();
	
	return 0;

}

and i still get a garbled screen :(

help!!

Maybe somebody could send me a already converted pic so i could test the display code??


Thankyou
 
I think you need a raw picture with no header and such..

I tries similar things and I also get a garbled picture.. You canr recognise it, but its not showing right. I also tried gp_SetPixel16 but it reboots the gp
 
Gah...!

Got it to work with header file. Mr.Mirkos converter is the problem I think. I used the Gpconvert program on Window$ and it converted properly. I will try and find out the problem with the converter later on.

Thanks for your help guys
 
I use GPconverter, too, because that weird format that mirko uses
Try this but keep in mid, this functions use the real coords...
Code:
/*********************************************************************
 *	Inline functions to check a point is inside the screen boundary.
 *  coded by Joel Lairo(21/10/03)
 */
inline int withinWidth(int x)
{
	return ((unsigned int)x < WIDTH);
}

inline int withinHeight(int y)
{
	return ((unsigned int)y < HEIGHT);
}

inline int withinScreen(int x, int y)
{
	return (withinWidth(x) && withinHeight(y));
}

/*********************************
 * Substitute for gp_putSprite()
 * no clipping yet! FIXME!
 */
void drawSprite(unsigned short *sprite, unsigned short sprite_x,
                unsigned short sprite_y, int put_x, int put_y,
                unsigned short *framebuffer)
{
     int xx,yy,i;
     u16   color;

     i=0;
     for (xx=0; xx<sprite_x; xx++)
       for (yy=0; yy<sprite_y; yy++)
       {
        color = sprite[i++];
        if(withinScreen(put_x+xx, put_y+yy))
          //gp_SetPixel16(put_x+xx, 239 - (put_y+yy), color, framebuffer);
          *(framebuffer +(put_y+yy)+(240*(put_x+xx)) ) = color;
       }
}
 
Back
Top