ofImage greyscale setFromPixels

I’ve got the following:

setup:
img.loadImage(“testgs2.jpg”);

update:
newImg.setFromPixels(img.getPixels(), img.width, img.height OF_IMAGE_GRAYSCALE, false);

Works fine with color images, but with greyscale it goes this way:

I didn’t see anything that looked too out of place in the ofImage code. Anyone else seen this?

  • edit -
    hmm. thought I had this fixed, and I did, sort of, changing this:

newImg.setFromPixels(img.getPixels(), xPx, yPx, OF_IMAGE_GRAYSCALE, true);

to

newImg.setFromPixels(img.getPixels(), xPx, yPx, OF_IMAGE_COLOR, true);

makes it show up fine, but I’m building out an array of pixels for edge detection, so I have a greyscale image that I want to display as a greyscale image.

it looks like the underlying pixels are color, even if the image is grayscale. No worries as you can change the type:

try:

  
  
img.loadImage("testgs2.jpg");   
img.setImageType(OF_IMAGE_GRAYSCALE);  
....  
newImg.setFromPixels(img.getPixels(), img.width, img.height OF_IMAGE_GRAYSCALE, false);   
  

take care!
zach

Ah, cool, I didn’t notice that setImageType called FreeImage_ConvertToGreyscale, I was setting the image type before loading the image:

img.setImageType(OF_IMAGE_GRAYSCALE);
img.loadImage(“testgs.jpg”);

Doesn’t quite do the trick; shoulda looked a little closer :slight_smile: Thanks!