24Bit BMP image treated as a 48Bits image?
Posted: 2013-11-29T23:38:00-07:00
Hello,
This is my first time with ImageMagick. I read a 24bit BMP file (8 bits per channel) and when i iterate pixel by pixel the pixels are 16bits per channel. What is happening?
this is my code:
If i read a 24 bits image i think i should edit it like a 24 bits image. what can i do?
Thanks a lot!.
This is my first time with ImageMagick. I read a 24bit BMP file (8 bits per channel) and when i iterate pixel by pixel the pixels are 16bits per channel. What is happening?
this is my code:
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <wand/MagickWand.h>
#include <string.h>
int main(int argc,char **argv)
{
MagickWand *imagen, *imagen_salida;
PixelIterator *iterator;
imagen = NewMagickWand();
MagickReadImage(imagen,argv[1]);
PixelWand **pixels;
iterator = NewPixelIterator(imagen);
MagickPixelPacket pixel;
///////////
register ssize_t x;
size_t width;
ssize_t y;
///////////
//******************ITERACION PIXEL POR PIXEL***********************
for (y=0; y < (ssize_t) MagickGetImageHeight(imagen); y++)
{
pixels = PixelGetNextIteratorRow(iterator,&width);
if (pixels == (PixelWand **) NULL) break;
for (x=0; x < (ssize_t) width; x++)
{
PixelGetMagickColor(pixels[x],&pixel);
pixel.red = 65535 - pixel.red;
pixel.green = 65535 - pixel.green;
pixel.blue = 65535 - pixel.blue;
//pixel.index = SigmoidalContrast(pixel.index);
//printf("\nr: %g", pixel.red);
PixelSetMagickColor(pixels[x],&pixel);
}
(void) PixelSyncIterator(iterator);
}
//******************************************************************
/* Write the image then destroy it. */
MagickWriteImages(imagen,argv[2],MagickTrue);
imagen = DestroyMagickWand(imagen);
iterator = DestroyPixelIterator(iterator);
MagickWandTerminus();
return 0;
}
Thanks a lot!.