ID:1889754
 
(See the best response by Kaiochao.)
Code:


Problem description:
I'd like to grab a list of colors from an icon. is there a simpler way than looping through each pixel and icon state and grabbing all of the colors in the image?
Nope. Why?
In response to Kaiochao
How does DM list all the colors of an icon? It seems like there's some sort of reference to it somewhere.

It's useful for icon editting, for instance if i have an image with 30+ colors and I want to change all the colors to the same value.
Or if I want to swap colors out - various things.
DM cheats; since it can load up the icon, it can just look at the direct data. There's no internal function for getting a list of colors, although I can see the value in one.
I remember when I requested GetPixel() back in the day and was sad when it didn't come with SetPixel() (but DrawBox() worked so I was happy again). I posited the idea that calling the proc with no arguments would cause it to return a list of colors used in the icon with the format being something like

list("[x],[y]"="#RRGGBBAA") but it was ultimately decided that the format was pretty unfriendly and the conversation didn't really go too far beyond that.

I'd definitely love a quick way to grab all of the colors myself. Calling GetPixel() recursively is slooooow.
In response to Nadrew
Terribly slow. lol
Another question, is it possible to Grab a certain section of an image?
For instance, by color-



like in this image- if i wanted to grab each green block by it's SW and NE corners based on the color i found as i looped through each pixel.

Then copy that space - what apsects of DM would i look at in order to get started on doing that?
In response to Avidanimefan
Best response
what apsects of DM would i look at in order to get started on doing that?
* Nested for() loops, to go over every pixel
* Working with the /icon datum:
* * icon() to load up your sheet
* * icon.GetPixel() to check the color of each pixel
* * icon.Crop() to change the icon to a certain rectangle of it
* * icon.Insert() to insert your cropped frames into an icon
It seems I've already got 1/2 of that coded then.
Well, a little more than half.

Just need to work out the details.