How to keep Greyscale “Color Space”

I am, sometimes, working with gresy scale images (with GIMP), then I resize them using a Xojo created application.

In the GIMP, I set the color space mode to grey scale, but this is lost (set back to RGB) when I resize it using my utilities application.

Is it possible to change that (in my Xojo project --> Utilities Application) ?

Emile,

I did some quick googling using “Xojo” “grayscale” and “Xojo” “greyscale”, and found this thread:

Using RGBSurface.Transform to Grayscale a picture
http://forums.realsoftware.com/viewtopic.php?p=235221&sid=fd1b8a373e3f8c11aa379a9471d48f73#p235221
(props to Andrew Lambert for also referencing this thread)

Check the methods GreyScale and GreyScale2 that doofus provided.

What is not clear is whether/how the greyscale is preserved when writing the Picture back to disk. It may also depend on the picture format that is being saved (jpg vs. gif. vs. bmp).

I remember a while ago trying to save BMP as indexed color or greyscale. Even with the help of MBS ImageMagick plugin, it never worked. Seems Xojo is unable to save anything but RGB.

Maybe some declares could do otherwise, but I am not aware of any at this time.

Hi Emile

If you have access to the MBS plug-ins there are functions that allow you to load grayscale images into a RB picture or into memory blocks. The MBS functions give you much more control over the Xojo image reading functions. For example, you can read meta-data or you can read the raw pixels bypassing any colour management that the operating system might automatically apply when using the Xojo functions. MBS also has functions for writing out grayscale images.

The code example mentioned by Thomas converts a colour RB image into a RB grayscale image. The RB Picture format is still RGB but the result is that for each pixel, R=G=B.

If you have loaded a grayscale image then you shouldn’t need to use that code unless you have drawn something non grayscale (R!=G!=B) into it.

I would definitely take a look at the MBS plug-ins. I also recommend the Einhuger plug-ins as they also have some very useful image related functions.

Kev.

As far as I know, if you really want to change the colorspace you will have to use plugins or declares – the default Xojo color space is RGB. So yes: Either you go for a workaround like equalizing RGB values (which will still be using RGB formats then though) or you’ll have to use one of the mentioned plug-ins or other libraries to create images that really use grayscale.

Thank you all for your advices.

Fortunately, the resized images are 600 pixels height (not so large); unfortunately, I have many of these (disk footprint, internet uploads/downloads…)

Thank you all for your advices.

Fortunately, the resized images are 600 pixels height (not so large); unfortunately, I have many of these (disk footprint, internet uploads/downloads…)

Xojo (then REALbasic / Real Studio) is able to save greyscale images, but it uses a RGB color profile.

When I saw the link contents, I recall it. I goes that way, long time ago (change a color image to greyscale).