Utilisation CxImage

incognito76 Messages postés 3 Date d'inscription mardi 5 février 2008 Statut Membre Dernière intervention 17 mars 2008 - 6 mars 2008 à 19:53
cs_rt15 Messages postés 3874 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 7 novembre 2014 - 7 mars 2008 à 12:05
Bonjour,


j'essaie depuis deux semaines en vain de stocker une image Bitmap (8 bit grayscale)

dans un tableau où les élements correspondraient  aux intensités des
pixels (ou niveau de gris).J'ai vu sur le
net(http://www.codeproject.com/KB/graphics/cximage.aspx) qu'il existait
une  classe  nommée CxImage qui permettaient de charger plusieurs
formats d'images(BMP,JPEG,TIFF,MNG,PNG,RAW,etc...) , de calculer des
histogrammes,transformer un Bitmap en JPeg, etc....Mon problème est que
j'ai écrit un programme pour stocker mon Bitmap(8bit,256x256) dans un
tableau,je n'ai aucune erreur de compilation mais je ne suis pas très
sûr d'avoir utilisé les fonctions appropriées

Quelqu'un qui s'y connaitrait avec CxImage pourrait-il me donner des indications par rapport à mon code suivant:?


#include"ximage.h"

#include<stdio.h>

#include<windows.h>

#include

using namespace std;


int main(){

CxImage image;

image.Load("nom du fichier Bitmap",CXIMAGE_FORMAT_BMP);


DWORD width,height,BitPerPixel;

// largeur du Bitmap

width=image.Getwidth();

//Hauteur du Bitmap

height=image.Getheight();

//Tableau pour stocker le Bitmap

double *GrayArray=new double [heigth*width];

BYTE index;

//Tableau servant à stocker le rouge,vert et bleu

BYTE *red=new BYTE [heigth*width],*green=new BYTE [heigth*width],

*blue=new BYTE [heigth*width];

int BytePerScanline,cx,cy;

BitPerPixel=image.GetBpp();

BytePerPixel=(BitPerPixel)/8;

//Nombre de Bytes par ligne du Bitmap

BytePerScanline=(width*BytePerPixel);


for(cy=0;cy<height;cy++){

               for(cx=0;cy<width;c++){

       index=image.GetPixelIndex(cx,cy);

RGBQUAD  Color=image.GetPixelColor(cx,cy,true);

red [index+2]  =Color.rgbRed;

green [index+1]  =Color.rgbGreen;

blue [index]  =Color.rgbBlue;

//Formule permettant de déterminer le niveau de gris

GrayArray[index]=0.3*red[index+2]+0.59*green [index+1] +0.11*blue[index];

}

}

return 0;

}


J'utilise Microsoft VC++ 6.0 sur WinXP.

Merci.

Incognito

1 réponse

cs_rt15 Messages postés 3874 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 7 novembre 2014 13
7 mars 2008 à 12:05
Salut,

Alors comme ça on va voir la concurrence ?

La classe CxImage possède une méthode GrayScale.
0
Rejoignez-nous