More saving icons: updated Nov 15, 2009

Share your advanced PureBasic knowledge/code with the community.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: More saving icons: updated Nov 15, 2009

Post by netmaestro »

This doesn't make cursors per se it only writes them out to disk. That said, all you need for a complete solution is a valid object to save, just feed it to this code and you're there. In my first year of coding with PB I asked on these forums how I might create a cursor from a bitmap of my choosing. Sparkle replied with a sample and I still use variations of his code today. Here is the topic I found so helpful: http://purebasic.fr/english/viewtopic.p ... sor+bitmap
BERESHEIT
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: More saving icons: updated Nov 15, 2009

Post by collectordave »

Thats a good piece of code got it working with my .png files.

Thanks
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: More saving icons: updated Nov 15, 2009

Post by collectordave »

Just a quick question hopefully.

I am now saving .png files and .ico files. I have found that some colours do not appear in the .ico format. Downloaded and tried a .png to .ico convertor from the net with exactly the same results.

Is there a limited range of colours that can be used for icons?

Regards

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: More saving icons: updated Nov 15, 2009

Post by netmaestro »

Afaik an icon can display 24-bit colours so that should cover the spectrum, however they don't use the alpha channel. Transparency is realized with the use of a mask. Therefore any colour that has an alpha component may not receive a perfectly true rendering. That said, my code does have a size-minimization routine that first counts the colours actually used in the image and then chooses the smallest possible output format that will display them all. I suppose it's possible that I've outsmarted myself somewhere in there but I do remember that it all made sense at the time. But then, many a fiasco of galactic proportions "made sense at the time".
BERESHEIT
Post Reply