1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
void TramageImage::tramageimage()
{
//remplir la matrice::
int l=cimage.width();
int h=cimage.height();
QRgb **matrice_pixel = new QRgb*[h];
for (int i = 0; i < h; i++)
matrice_pixel[i] = new QRgb[l];
for ( int i=0; i<cimage.height(); i++ ) {
uchar *p = cimage.scanLine(i);
for (int j = 0; j < cimage.width(); j ++) {
int blue = int(*p++);
int green = int(*p++);
int red = int(*p++);
int alpha = int(*p++);
QRgb rgbValue = qRgb(red,green,blue);
matrice_pixel[i][j] = rgbValue;}
}
//redéfinir l'image
for(int i=0;i<h;i++)
{
for(int j=0;j<l;j++);
{
if (matrice_pixel[i][j] <= 127)
{
erreur=matrice_pixel[i][j];
matrice_pixel[i][j]=0;}
else
{
erreur=matrice_pixel[i][j]-256;
matrice_pixel[i][j]=256;}
matrice_pixel[i][j+1]=matrice_pixel[i][j+1]+erreur*(7/16);
matrice_pixel[i+1][j]=matrice_pixel[i+1][j]+erreur*(5/16);
matrice_pixel[i+1][j+1]=matrice_pixel[i+1][j+1]+erreur*(1/16);
}
} |