LoadPixmap() Problem
BlitzMax Forums/BlitzMax Programming/LoadPixmap() Problem
| ||
The problem is simple. In short: I cannot get LoadPixmap() to work. In detail: The problem is this function alone. I have tried loading several different images with this function. Jpg's, bmp's, 32 bit Targa's. The files I tried where all Power of 2 in size and made either by myself in photoshop CS2, or downloaded from the web somewhere. Everytime I try loading an image, the function returns Null. In order to make sure it's not something else in my program, I put the following code in an entirely new bmax file to try it out. local filename:string = "someimage.bmp"; Local pixmap:TPixmap = LoadPixmap( filename ); If( pixmap = Null ) Then print("Grmbl!@#"); else Print( "yay!") End If With each file I tried loading, the result is failure ("Grmbl!@#" get's printed). My system is Windows XP Pro. SP2. I have an NVidia GeForce FX 5700/PCI/SSE/3DNOW!. DireectX 9c and BlitzMax version 1.20. At this point I have only one solution. Load the image with LoadImage, then manually copy the pixeldata over to a newly created Pixmap. If this is going to work properly is yet unknown. Ill go try that now, but I hope im just overseeing something here and this can be resolved. |
| ||
If loadimage works then load pixmap works as well as it internally loads a pixmap and converts it ... sure you didn't framework something strange? |
| ||
Works for me. After creating an "entirely new bmax file" don't forget to Save As the code in the same directory as your someimage.bmp file otherwise it will not know where to look. |
| ||
stick a FileType check to see whether BlitzMax can see your image filelocal filename:string = "someimage.bmp"; If FileType("someimage.bmp")=0 then print "Can't find File" Local pixmap:TPixmap = LoadPixmap( filename ); If( pixmap = Null ) Then print("Grmbl!@#"); else Print( "yay!") End If |
| ||
Tried all of that unfortunatly. LoadImage/DrawImage, etc work perfectly. No problem with them Now I tried writing a routine to manually create a Pixmap with CreatePixmap(...), but this does not work either. Meaning I cannot copy the image data from the image over to a fresh Pixmap. Method PixmapFromImage:TPixmap( file:String ) Local img:TImage = LoadImage( file ); Local npm:TPixmap = CreatePixmap( ImageWidth(img), ImageHeight(img), PF_RGB888 ); Local ipm:TPixmap = LockImage( img ); Local pixel:Int; For Local y:Int = 0 To ImageHeight(img) - 1 For Local x:Int = 0 To ImageWidth(img) - 1 pixel = ReadPixel( ipm, x, y ); WritePixel( npm, x, y, pixel ); Next Next UnlockImage( img ); Return npm; End Method The first error occurs at: CreatePixmap( ImageWidth(img), ImageHeight(img), PF_RGB888 ); Fo the record, I tried using every available Format as argument, but the functions keeps returning Null. The second error occurs at: Local ipm:TPixmap = LockImage( img ); According to the docs, LockImage() returns a Pixmap, but this one returens Null as well, Eventhough the Image loads perfectly with LoadImage(). Im at a complete loss here :| |
| ||
Ok, it seems there is something weird with Module dependencies going on. if I remove all the 'Framework'/Import' tags from my project and just load the whole lot, it works perfectly. The fact that I can compile my project without getting any Missing dependency error's leads me to think I included everything I need. Framework Pub.OpenGL Import Brl.Basic Import Brl.StandardIO Import Brl.GLGraphics Import Brl.Max2D But it seems I am missing something that is referenced internally |
| ||
So you were making it up when you said the initial test was run as a separate bmx file (without the framework garbage)? |
| ||
Framework Assistant which suggests...Framework BRL.BMPLoader Import BRL.StandardIO ' modules which may be required: ' Import BRL.PNGLoader ' Import BRL.TGALoader ' Import BRL.JPGLoader for this code... local filename:string = "someimage.bmp"; Local pixmap:TPixmap = LoadPixmap( filename ); If( pixmap = Null ) Then print("Grmbl!@#"); else Print( "yay!") End If |
| ||
"So you were making it up when you said the initial test was run as a separate bmx file (without the framework garbage)? " No I wasn't. That's the one thing that still bothers me. The bare pixmap code from my first post still gives problems when I use it in an empty file. But it is in the same IDE instance as my project. the New file is in no way linked to the project and neither is the Build File locked to the project or this seperate file, yet the IDE/Compiler still seems to think that the Includes/imports from my project also apply to the seperate, empty bmx file. I assume that id why it did not work in the new file either. @tonyg : Thanks for the link to that program. Should save me some future headaches :) |
| ||
The reason I always get that sort of error are 1) The path on image is wrong. or 2) I forgot to add the file type, Ie Image.bmp. Also I believe, (hahah), that a project is all compiled in some editors, so maybe you had included the first listing in the project, and the first file had the framework. |
| ||
The bare pixmap code from my first post still gives problems when I use it in an empty file. But it is in the same IDE instance as my project. the New file is in no way linked to the project and neither is the Build File locked to the project or this seperate file, yet the IDE/Compiler still seems to think that the Includes/imports from my project also apply to the seperate, empty bmx file. I assume that id why it did not work in the new file either. What happens when you load the 'bare pixmap code' into the IDE on it's own? What IDE are you using? What happens when you use MaxIDE? |
| ||
I am using MaxIDE. When I load that code into a fresh instance of MaxIDE, without all the Framework/Import stuff, it works fine. The Pixmap problem is solved if I load the proper framework/includes. I'll just have to watch out when opening a 'fresh' file in the same IDE instance as my project, as appearantly it isnt as 'fresh' as I would expect it to be. MaxIDE atomaticly considers it to be part of my project. |
| ||
MaxIDE atomaticly considers it to be part of my project. No it doesn't. Create a new file and run the following: Print CurrentDir() |
| ||
MaxIDE atomaticly considers it to be part of my project. MaxIDE has projects?!? |