If you want to create 10 images you must have 10 image objects.Otherwise the last image that you create will be there in the imageObject myimage...
I want to have the method return an image, which I then run createimage on again to store in an array of images. All I want the function to do is to perform createimage on a filename and return a temporary image which i pass out as the return value.
check by adding the /res/to the image name.I suppose you are keeping the images in the res folder of your project.
Thanks, but there's nothing wrong with the location, or file format. It works when I hard code the filename and load 1 image, and now I want to change the function so that I can load a file whose filename is passed in as a string, and I want the function to return the image which has just been loaded.
your CreateImage() creates an immutable image.
The Image class has two forms: mutable and immutable. The immutable image is created when another image (or the resource containing the image) is supplied to the createImage() method; while a mutable image is created when only the image dimensions are supplied.
What you are trying to do looks ok so I would
like to see a bit more code and then put print
statements in to see what is going on.
I think I've got it working. There's something funny about the way my old copy of Paint Shop Pro saved my gifs. I loaded them all into Paint and then saved them again and those ones work fine. I did a file diff between them and there are some difference, but they're binary, so god knows what. It's not the classic `save as a jpg but give the filename the gif extension` bug which catches people out sometimes though!
I've reworked my code substantially in the process - I've got my image loader working now, and I convert the loaded image to a sprite immediately, so I don't have two calls to createImage any more. I have, however, lost the transparency I had before, so I'll have to arse around with a graphics program a little later on.
In case you're wondering, I'm basically writing the game Vexed/Puzznic in J2me. It's out there on sourceforce, only it's in C or C++ or something, but I'm not using any of their code/logic, apart from the logic to decrypt the level data. This is my first java program, and it's going ok so far. I might release the source at some point so people can pick apart my code and tell me how to do it properly!
Thanks for your help, perhaps I'll ask some more stupid questions later on.