PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

create surface problems???

Hi all

I'm making a very quick little image browser using the GapiDraw library - it is a very basic app with a blit of the image surface to the backbuffer

The browser reads a filename from a line in a text file (the line number depends on the offset controlled by the users keypresses)

when the user presses a key to increase the line offset I increase/decrease the line offset, read the new line from the text file, and then do :-

m_loadedimage.CreateSurface(GDSURFACE_SYSTEMMEMORY,tname);

where m_loaded image is a CGapiSurface and tname is the filename from the text file

the problem is that sometimes the image doesn't change to the new image - yes the filename is correct, and present, and it doesn't do it with the same image every time - images are varying sizes, types and depths

so I set another key to just call the loading routine with the current offset, and again, that works sometimes - but not all the time

I even tried doing :-

m_loadedimage.CreateSurface(GDSURFACE_CLEAR, 16, 16);

before my load line, just to make sure that the surface had no properties the same as the loaded images

am I doing something wrong?? or is it just that GapiDraw doesn't like doing this for some reason?

all help gratefully received

muff
what I also realised is that this has ramifications for on the fly loading in general, say between / during levels to change tilesets or character graphics

so I can't believe that no-one has come across it before - therefore I can only assume that I'm doing something wrong - but don't know what
Are you checking the return code from the CreateSurface() method? That would be my first step in figuring this out. I've not tried loading various size images onto a single surface, so I can't vouch for it working.
muff:

(1) How large are the images you are loading?
(2) Are you using GapiDraw 1.04b or 2.01b?
(3) What formats are the images you are loading?

I would guess that you are simply running out of memory on your device. Check the return code from CreateSurface as ppcStudios suggest, I think it might return OUTOFMEMORY.
just to clarify what I'm trying to do

what I want to do is replace the WHOLE graphic on a surface with the new one from the disc (well in this case the sd card) - imagine loading the tiles for level 2 over the tileset for level 1 in a game - both would be stored on a surface call m_tiles for example, you'd just be reloading between levels

I no longer need the old image, just the new one, but the reference needs to be the same

SBL
1. the images are 220x176 pixels at the largest, and the biggest one is a 35k jpeg

2. using GapiDraw 2.01b

3. jpeg + png

I know that the device is definately not out of memory, I have a memory display on the screen at the same time (though it does go down if I hold down the reload key on the same image which I was suprised by - I thought reloading the same image it wouldn't reallocate memory), and also if I press my reload key then sometimes the image does appear (though sometimes not and that's the problem)

it's just not loading the image 'onto' the surface - I added a GetWidth() + GetHeight() of the image surface to the display and they are both showing 0

I've also tried pausing after issuing the createsurface command in case there was a need for a delay to load - this didn't help

I even tried removing the load call from within the ProcessNextFrame function and put it the the KeyDown function - this is all based code from one of the sample Gapi examples

as I said originally this was a pain because of the little image browser I was trying to make wasn't working, but I then realised that it had implications for mid-application graphic loading

my previous projects loaded all the graphics during the CreateSurfaces stage at the start of the game, and didn't try to load during the game itself

TIA for any advice and help, this has already cost me a lot of hair ;)

muff
sorry forgot to put username in above
My sincerest apologies guys/gals :(

it wasn't GapiDraw that was the problem at all, it turns out it was my filename loading/converting code

and on top of that I was leaving the filehandle to the list open, so that was causing the strange memory behaviour I was seeing - doh!

it's all working now

I feel that the kid who cried wolf right now :(

thanks for the replies guys, sorry to have wasted your time

muff