Kinda like this... http://www.coolphptools.com/color_extract. Is this possible from within Corona?
Possible to extract color values from a bitmap image?
Nov 20 2019 06:54 AM
Sampling form the display isn't the best option as the results may depend on the filtering and/or scaling of the image and you also need to display the image first (and handle cases where the image is bigger than the actual display resolution).
A probably better alternative is to use Starcrunchs extension https://marketplace.coronalabs.com/corona-plugins/byte-map
- pixec likes this
@Michael Flad, Ah, that's a good solution - probably much faster than color samples.
Is there any reason you would use Starcrunch's byte-map extension instead of say Corona's memoryBitmap? I think either one would be a smarter approach than the solution I offered above.
As far as I can tell (if I didn't miss anything in the docs) there's no way to load image files into a memoryBitmap or transfer the contents of an existing texture into a memoryBitmap. So you'd have to also implement a jpg/png loader to work with existing images.
- sporkfin likes this
Basically what @Michael Flad said.
It's sort of incidental in my plugin's case that it can be used to get and set individual pixels, as it's largely intended for bulk operations like full images or large subregions. It actually began life as some methods added to memory bitmaps, so I do have code somewhere that will populate them from bytes; that's a recompiled plugin though, not something that could just be dropped in.