Need help to handle raw ARGB bitmap greater than 512x512

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

Moderators: cheriff, TyRaNiD

Post Reply
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Need help to handle raw ARGB bitmap greater than 512x512

Post by sauron_le_noir »

I there i'm have ported the execelnt sumatrapdf library to the psp but i stick with a problem when rendering the pdf i've got a buffer ARGB greater than 512x512
In the documentation of oslib or Easy_Accelerated_Image_lib they say that
the image must not greater than 512x512.

Is there a way to handle bitmaps that are greater than 512x512 or must i do
all by myself dividing the buffer in shunks of 512x512.

Another question can malloc use the extra 32mega of a psp slim ?
many thx for the replies (sorry for my poor english)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Look at the graphics.c blit code - it shows how to handle >512 horizontally. If you go >512 vertically, you'll have to do something similar for that direction as well. Basically, you're splitting the image up ANYWAY because the texture cache only handles 32 to 128 wide (depending on the depth). So most blit routines slice the image into 32 pixel wide stripes. You use the stride to allow for the fact that the image width does not equal the width you are blitting.

If you look at my refresh code in Basilisk II, you'll see where I split the blit both horizontally and vertically. My refresh handles >512 wide and up to 1024 vertically.

To get the extra memory on the Slim, you need to add "PSP_LARGE_MEMORY = 1" to the makefile.
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

OK so when i but PSP_LARGE_MEMORY = 1 in my makefile the malloc function
automaticly give me the extra 32 Mega right ?
and has no effect when my homebrew run on a fat psp (just less heap space availaible) for know i need +- 20Méga of ram to rendering pdfs but i can use
the extra 32 mega for bitmap page caching thx a lot for the tips
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Yes. Specifying large memory only affects the Slim - the Phat ignores it. The memory is available to plain allocation commands as long as you set the heap size to max or a small negative value.

Code: Select all

PSP_HEAP_SIZE_MAX();
takes all available user memory to the app.

Code: Select all

PSP_HEAP_SIZE_KB(-kilobytes);
takes all available memory except for the number of KB specified. I generally use

Code: Select all

PSP_HEAP_SIZE_KB(-256);
in my stuff. That leaves 256KB for threads and stuff. The heap size goes in your main.c, not the makefile (in case you were wondering).

Using the negative value is great if you want something that works on both the Slim and the Phat with a single executable while still giving all the extra memory on the Slim.
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

many thx for the replies just wat i need.
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

can i create a bitmap > 512 with this
bitmap_page = createImage(pix->w, pix->h);
i fill bitmap_page->data with the correct data

to blit i use for example
blitAlphaImageToScreen(0,0,200,200,bitmap_page,0,0);

or must i realy divide the bitmap in severall bitmaps ?
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

You can create any size image. To load any size image, you have to comment out this block of code from the loadImage function:

Code: Select all

	if (width > 512 || height > 512) {
		free(image);
		fclose(fp);
		png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
		return NULL;
Note that graphics.c doesn't handle vertical sizes >512, only horizontal. You'll have to modify the blits in the file to handle vertical as well as horizontal for heights >512.
a_noob
Posts: 97
Joined: Sun Sep 17, 2006 8:33 am
Location: _start: jr 0xDEADBEEF

Post by a_noob »

Look at openTri game engine it supports > 512x512 (as long as the image fits into memory openTri can handle it)

Code: Select all

.øOº'ºOø.
'ºOo.oOº'
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

many thx a_noob the openTri contrains the tri library it's even better than the
oslib. I've now a pdf reader for psp i will be release soon just correcting some
problems with the zoom fiunction
Post Reply