FreeImage LIB
Blitz3D Forums/Blitz3D Programming/FreeImage LIB
| ||
Hi, has anyone got this to work with Blitz3d. I have copied the \decls files into the \userlibs dir. I have included the FreeImage3d.bb in my app. I have copied the 2 dlls into my apps main dir. It appears to comile OK but when I run it I get "User lib not found". Any thoughts |
| ||
You have to copy the dlls as well :P Have you tried using 2d? |
| ||
I have copied them to my apps dir and to \userlibs. Still no joy! And when I build a release do I have to include the 2 dlls? Do you mean the 2d version? Its for Blitz Plus... It fails on "FI_FileEXT(FI_FIFType,1)=FI_GetFIFDescription(FI_FIFType) " Surely someone must use this library... How do other people save to PNG? |
| ||
Fixed it. Removed the "\data" path in the FreeImage.decl file. But what filees (if any) do I need to ship with my app? Just the 2 dlls I guess? Also the saved image is screwed. The colours are all screwy! ARGGGHHH! I'm creating an image then using CopyRect to copy the back buffer to it then saving the image... Any thoughts? |
| ||
Just the two dlls. |
| ||
Any idea why the image colors are all screwy? |
| ||
Maybe to do with bit depth? |
| ||
But how do I fix it? Does anyone use this lib? |
| ||
I've used it in C++, but I'm not sure if you're using the C++ .dll directly or using a 3rd party blitz wrapper? |
| ||
I'm using a Blitz wrapper... |
| ||
Bump! Seriously though does anyone successfully save images to .PNG? If so how???? |
| ||
I've saved images to PNG using FreeImage with BlitzPlus (Screenshot Magic uses it) but I ended up writing my own wrapper using Snartys code as a reference. What Perturbatio said sounds right to me, it is most likely the image depth that is causing the strange colours. Take a look at the depth conversion function which is called inside the SavePNG function (just prior to saving - I think it's FIQSend?). Also what colour depth is your desktop set at, 16-bit or 32-bit? 16-bit can affect the images colour depth iirc. If you still can't get it to work, bump this thread and I'll have a play with it here and get back to you. |
| ||
Boiled Sweets, I was a little curious so I had a look anyway. The image colour corruption is definitely due to the desktop being set at 16-bit. If you set it to 32-bit it works ok. The problem occurs because the FIQSend function is only set up for 32-bit colour depth mode. In the FIQSend function you have this code: I suspect the function 'FI_PeekIntEx(iBuffer,offset)' would need to be replaced with the FI_PeekWordEx(iBuffer,offset) function, meaning it peeks 2 bytes instead of 4. The offsets would also need changing, but I'm not sure how to implement this in practice as I don't know how those offsets were calculated. Maybe Snarty can help point you in the right direction, if you email him, he may know what they should be for 16-bit colour depth. Once you know the settings for both modes, you can then detect the depth and use the correct function for that mode, 16-bit or 32-bit. |
| ||
Bump Have you sorted it then? :) Was wondering if you got those 16-bit offsets... |
| ||
VIP3R, No. I'm a little out of my depth on this one. I'm still trying to decypher what you recommended. I am amazed that no-one here appears to be able to save to .PNG format as it is the image format of choice... Could you help? |
| ||
Yeah, I'll have a look into it, can't promise anything tho ;) I did manage to solve this with the B+ version, but the commands I need don't exist in B3D... LockedPitch() LockedPixels() etc. |
| ||
I have successfully created files in PNG format without issues, right "out of the box" so to speak....i use freeimage to generate my web graphics actually. |
| ||
ouch! ive never ever seen this! i have no way of trying that code here either.... (im at work) |
| ||
All I'm doing is creating a tmp image. Copying the front buffer to the tmp imaage then calling the ImageLib "SavePNG" function passing in the tmp image. The bluey/yellow circular mesh in the sample picture should be grey. The yellowy floor ceiling is also supposed to be a greyisg colour. |
| ||
bump <hic> |
| ||
i will be taking a look at this tomorow. il let you see the results of a few screen modes |
| ||
FIXED! *wipes sweat from brow* Ok, replace the FIQSend() function in your FreeImage3D.bb with this new one: Works properly now in both 16-bit and 32-bit modes ;) |
| ||
Firstly EXCELLENT WORK! So...If iPitch=3200 ROffset=112 GOffset=116 BOffset=120 End If If iPitch=1600 ROffset=120 GOffset=116 BOffset=112 End If appears to have fixed it. What was it all about? How did you fix it? |
| ||
Well, trial and error :) I spotted that in 16-bit mode, the red and blue bit masks were reversed. It was just a case of detecting the depth, then reverse the bit masks with 16-bit modes. I don't understand why Snarty didn't cater for this in the first place, I had the same problem with the 2D wrapper. |
| ||
Have you emailed the update to Snarty? |
| ||
No, the last time I mentioned a bug in the wrapper (memory leak) to Snarty, he never bothered to reply or implement an update. Suppose he could be too busy to work on it? Maybe I should release my own FreeImage wrapper? |
| ||
YUP! I'm amazed more people don't use it... |
| ||
woohoo, Yes, i could get the same error and that fixed it. vip3r, thanx :D |
| ||
You're welcome :) |