FreeImage and Displaying Images *SOLVED*

New to FreeBASIC? Post your questions here.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: FreeImage and Displaying Images

Postby datwill310 » Apr 08, 2017 11:56

MrSwiss wrote:Hi datwill310,

I've no idea how (if at all) sGUI is influencing on Alpha etc. But in many cases Alpha on
it's own produces not really what one might expect.
Below a Union is used to be able to access every single Color-Channel: (aa, rr, gg, bb).
The combination of the same manipulation on Alpha- + Red-Channel seems to get the
expected result, just *uncomment* the red in the code, to check it out:
A little something about posting: plse. don't copy the whole post (comments, code and all),
just the section, you're referring to. This saves a lot of resources of the forum.

Ok, understand. Will study your snippit tonight. Thanks for your input!
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: FreeImage and Displaying Images

Postby leopardpm » Apr 08, 2017 15:11

I have always really liked PNG files because they support transparency and have very good compression. BUT...

Due to FB's lack of direct PNG support (requires a library, etc) which inevitably leads to issues like you are having, I have come across a method which gives all the benefits of Transparency as well as requiring no external library or other things. FB handles 32bbp images without issue using the PUT command, the only issue is with the BLOADing from storage. and, actually, FB does support BLOADing of 32bpp BMP files! The problem is that most paint programs do NOT support alpha in the BMP format.

Some one made a plugin for the Paint.Net program which allows it to save images in BMPX (32bpp BMP), which FB can BLOAD directly, giving you full and easy access to images with alpha. There is only one real issue: there is no compression of the image. But, with the amount of storage available these days, this is a non-problem, really.

Here is link to download Paint.Net: https://www.getpaint.net/

This link should be for the plugin: https://forums.getpaint.net/applications/core/interface/file/attachment.php?id=3846
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: FreeImage and Displaying Images

Postby datwill310 » Apr 08, 2017 15:58

leopardpm wrote:I have always really liked PNG files because they support transparency and have very good compression. BUT...

Due to FB's lack of direct PNG support (requires a library, etc) which inevitably leads to issues like you are having, I have come across a method which gives all the benefits of Transparency as well as requiring no external library or other things. FB handles 32bbp images without issue using the PUT command, the only issue is with the BLOADing from storage. and, actually, FB does support BLOADing of 32bpp BMP files!

There is only one real issue: there is no compression of the image. But, with the amount of storage available these days, this is a non-problem, really.

I chose the PNG format because it uses A LOT less data than BMP files. A lot less. PNG uses a fraction of what BMPs use: a small fraction generally speaking. Especially as other pieces of software use the format, I would like to too. I've also managed to get one of these libraries to work with FB at all: I think that's a big feat for me: something which would be totally wasted if I were to chuck it all away for the Bitmap format.

Still, thanks for reminding me that there is such an option (an option which I inevitably may have to take :/).

I mean, I could use some zLIB/BMP setup, but THAT seems like more trouble than it's worth...

And yes. I use GFIE to create alpha images. I prefer this piece of software to Paint.NET, but GFIE is not very good with standard shapes (almost 0 suport).
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: FreeImage and Displaying Images

Postby leopardpm » Apr 08, 2017 16:12

I chose the PNG format because it uses A LOT less data than BMP files.
yes, I am a memory saver too - a remnant from much earlier times when every byte mattered. But, honestly, how many total images do we have on our hard drives - probably measured in MB (in their raw format, not compressed), which is virtually nothing compared to the GB and TB we have available these days. Even so, I appreciate your view as I also like things 'lean & mean'. I still hesitate when using BMPX due to its uncompressed nature, but I soon forget about my discomfort when I realize the time saved in tackling my true project goal - which is not to learn how to incorporate a foreign library and its respective routines seamlessly into my project, or to spend time troubleshooting why my simple project will not work correclty because I mis-used the library, or broke some hidden 'rule'...

ie: "It is only mandatory to use the GFX_SHAPED_WINDOW flag."

Here is a discussion about this very debate: http://www.freebasic.net/forum/viewtopic.php?f=17&t=24698&hilit=Frustrated+need+to+discuss

and there are many other discussions as well.
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: FreeImage and Displaying Images

Postby leopardpm » Apr 08, 2017 16:14

datwill310 wrote: And yes. I use GFIE to create alpha images. I prefer this piece of software to Paint.NET, but GFIE is not very good with standard shapes (almost 0 suport).
what is GFIE?

I just noticed another potentially helpful plugin for Paint.Net - It is a spritesheetmaker which takes the layers in a PDN file and makes a single spritesheet (which could easily be saved as BMPX). Thus have a PDN file, with layers, for each animated sprite, work on it in that native format using layers which makes things easier to do when comparing one frame to the next, then export a BMPX for use in FB. Of course, this adds even more space used for each sprite, but again, who really cares at these micro-levels of storage use?
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: FreeImage and Displaying Images

Postby datwill310 » Apr 08, 2017 16:19

leopardpm wrote:what is GFIE?

GreenFish Icon Editor is a painting program which can do many cool things: like full alpha support, the creation of .ico files, as well as many more, batch converting image files, and even image extraction from .dll, .exe, and other archive files. Maybe even .jar files work! I've not tested it out yet.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: FreeImage and Displaying Images

Postby datwill310 » Apr 08, 2017 16:23

leopardpm wrote:
I chose the PNG format because it uses A LOT less data than BMP files.
yes, I am a memory saver too - a remnant from much earlier times when every byte mattered. But, honestly, how many total images do we have on our hard drives - probably measured in MB (in their raw format, not compressed), which is virtually nothing compared to the GB and TB we have available these days. Even so, I appreciate your view as I also like things 'lean & mean'. I still hesitate when using BMPX due to its uncompressed nature, but I soon forget about my discomfort when I realize the time saved in tackling my true project goal - which is not to learn how to incorporate a foreign library and its respective routines seamlessly into my project, or to spend time troubleshooting why my simple project will not work correclty because I mis-used the library, or broke some hidden 'rule'...

ie: "It is only mandatory to use the GFX_SHAPED_WINDOW flag."

Here is a discussion about this very debate: http://www.freebasic.net/forum/viewtopic.php?f=17&t=24698&hilit=Frustrated+need+to+discuss

and there are many other discussions as well.

I do see your point: and I've come across this discussion in search multiple times! If only we could incorporate PNG support so easily... ;D. I will still test out MrSwiss' code because PNG is still my preference, but if all fails, I will have to move over to 32-bit bitmaps :(
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: FreeImage and Displaying Images

Postby leopardpm » Apr 08, 2017 16:25

datwill310 wrote: I mean, I could use some zLIB/BMP setup, but THAT seems like more trouble than it's worth...

If I were still truly concerned with the amount of space used in my storage medium, then I would setup an automatic folder compression program that would work behind the scenes through the operating system - it would be invisible to the FB BLOAD command (hopefully) yet everything in the folder would be ZIPPED or whatever... I should think such a creature already exists out there on the net somewhere...

using the zLIB library is just another library to include into a project that makes things just a bit more complicated... my main problem is that my programming goes in fits and spurts - there may be months at a time that I do not program at all, and during this time-off period, I have forgotted how to do these mundane tasks like linking up to libraries and figuring out where things need to be stored (DLLs) for the compiler to link to them correctly. This leads to me needing to 're-learn' each time, and that is a lot of time wasted for me... other folks are probably better at remembering than I... this is just my own issue, and solution.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: FreeImage and Displaying Images

Postby datwill310 » Apr 08, 2017 17:41

leopardpm wrote:
datwill310 wrote: I mean, I could use some zLIB/BMP setup, but THAT seems like more trouble than it's worth...

If I were still truly concerned with the amount of space used in my storage medium, then I would setup an automatic folder compression program that would work behind the scenes through the operating system - it would be invisible to the FB BLOAD command (hopefully) yet everything in the folder would be ZIPPED or whatever... I should think such a creature already exists out there on the net somewhere...

using the zLIB library is just another library to include into a project that makes things just a bit more complicated... my main problem is that my programming goes in fits and spurts - there may be months at a time that I do not program at all, and during this time-off period, I have forgotted how to do these mundane tasks like linking up to libraries and figuring out where things need to be stored (DLLs) for the compiler to link to them correctly. This leads to me needing to 're-learn' each time, and that is a lot of time wasted for me... other folks are probably better at remembering than I... this is just my own issue, and solution.

I agree with you about zLIB, but I personally don't trust background tasks: even if they are Microsoft/Windows processes. I'm sure a lot of others don't either.
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: FreeImage and Displaying Images

Postby leopardpm » Apr 08, 2017 17:43

datwill310 wrote:
leopardpm wrote:what is GFIE?

GreenFish Icon Editor is a painting program which can do many cool things: like full alpha support, the creation of .ico files, as well as many more, batch converting image files, and even image extraction from .dll, .exe, and other archive files. Maybe even .jar files work! I've not tested it out yet.


Here is the plugin for Paint.Net for Icons, Cursors, and Animated Cursor files: https://forums.getpaint.net/applications/core/interface/file/attachment.php?id=10208

don't want you to compromise any filetype compatability if you choose to change to Paint.Net as your goto paint program...

I bet there is a 'batch conversion' plugin also... I just haven't searched for it yet... that is handy, especially if going to wholesale convert all the PNG files to BMPX files...
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: FreeImage and Displaying Images

Postby leopardpm » Apr 08, 2017 18:49

I just downloaded a Sprite Animation plugin for PDN... will try it out as well... I can't believe the amount of the plugins available for PDN... lots of interesting and useful stuff in there!

https://forums.getpaint.net/index.php?/topic/14848-spritesheet-animation-plugin/

Tried both the Spritesheet creation and Spritesheet animation plugins, they work good - the animation one co9uld be very helpful in the creation of animation frames... as well as transferring info over to FB in the form of a text file that describes which frames go to which animation - requires more testing for me at this point though.

BUT, i will stop posting here as I have kinda hijacked the thread from the original post... this thread isn't about PDN, but rather FreeImage...
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: FreeImage and Displaying Images

Postby datwill310 » Apr 08, 2017 23:19

MrSwiss wrote:Hi datwill310,

I've no idea how (if at all) sGUI is influencing on Alpha etc. But in many cases Alpha on
it's own produces not really what one might expect.

I have just noticed something about the palette function cha0s made:

Code: Select all

sub palette_using_dib(byval dib as FIBITMAP ptr)
   dim as RGBQUAD ptr pal = _FreeImage_GetPalette(DIB)
   for i as integer = 0 to 255
      with pal[i]
         palette i, cubyte(.rgbRed), cubyte(.rgbGreen), cubyte(.rgbBlue)
      end with
   next
end sub

I noticed that the alpha channel isn't set! Looking up the command a bit more and I am doubtful that the alpha channel is supported at all with this function (that is, palette):
FB Doc wrote:Parameters

Get
indicates getting palette information rather than setting palette information

index
palette index

color
color attribute

r
red color component

g
green color component

b
blue color component

Using
indicates using array of color values

arrayname(idx)
array and index to get/set color attributes

Also notice in that page that:
FB Doc wrote:The Palette statement is used to retrieve or customize the current palette for graphics modes with a color depth of up to 8bpp; using Palette while in a mode with a higher color depth will have no effect.

I am using depth 32. So this would be useless? Am not quite sure!
MrSwiss
Posts: 3657
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: FreeImage and Displaying Images

Postby MrSwiss » Apr 08, 2017 23:45

datwill310 wrote:I am using depth 32. So this would be useless? Am not quite sure!
It appears so, unless there are other procedures, to cope with 32bit (which then,
automatically includes Alpha).
As stated in the Manual: above 8bit's depth, all palette related stuff, is of no use ...
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: FreeImage and Displaying Images

Postby datwill310 » Apr 09, 2017 2:33

MrSwiss wrote:It appears so, unless there are other procedures, to cope with 32bit (which then,
automatically includes Alpha).
As stated in the Manual: above 8bit's depth, all palette related stuff, is of no use ...

I may have to go over to bitmaps. RIP PNG. Thanks again all of you for your help
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: FreeImage and Displaying Images

Postby datwill310 » Apr 09, 2017 13:30

:facepalm:
I was using pset as the blitting method instead of alpha...
Problem solved.

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 17 guests