Page 1 of 1
Question about using GetImagePixels
Posted: 2007-12-20T15:53:43-07:00
by rmagick
In RMagick, before I call GetImagePixels and SyncImagePixels I call SetImageType to set the type to TrueColorType. I can't remember why I did this and now I'm wondering if it's necessary. So, should my code ensure that the image is TrueColorType before calling GetImagePixels? What if the image has an alpha channel?
Re: Question about using GetImagePixels
Posted: 2007-12-20T17:45:06-07:00
by magick
If you are going to introduce new colors into an image it is best to ensure the image is DirectClass before you update the pixels. Call
- SetImageStorageClass(image,DirectClass);
Instead of SetImageType() because SetImageType() with a TrueColorType parameter converts the image to the RGB colorspace and turns off the alpha channel which is probably not what you want (in particular if the image happens to be alpha or if it is in the CMYK colorspace).
Re: Question about using GetImagePixels
Posted: 2007-12-20T18:15:16-07:00
by rmagick
Thanks for your advice! I thought that call looked fishy. I'll make the fix in RMagick asap.