[AD] getpixel and getr errors

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]




---------- Forwarded message ----------
From: frederico schardong <frede.sch@xxxxxxxxxx>
Date: 2009/1/17
Subject: Re: [AD] getpixel error
To: Coordination of admins/developers of the game programming library Allegro <alleg-developers@xxxxxxxxxx>


when I try set_color_depth(32), my laptop halt!!

set_color_depth(16) work.

Ok, It's work.. or not.

see the log now:

pix 75, x=0 y=0, r=75,g=90,b=8
pix 107, x=0 y=1, r=107,g=90,b=12
pix 139, x=0 y=2, r=139,g=90,b=16
pix 172, x=0 y=3, r=172,g=99,b=20
pix 172, x=0 y=4, r=172,g=99,b=20
pix 204, x=0 y=5, r=204,g=99,b=24
pix 204, x=0 y=6, r=204,g=99,b=24


the value of the pix everytime is the red. Why??



see:

start_allegro();
   
    set_color_depth(16);   
   
    BITMAP *imagem = load_bitmap("picture.bmp", NULL);
    BITMAP *imagem_gray = create_bitmap(imagem->w, imagem->h);
    PALETTE pal;
   
    get_palette(pal);


    int matrizPixel[imagem->h][imagem->w];
    rgb matrizRgb[imagem->h][imagem->w];

    printf("2 - Digite o caminho para o arquivo a ser salvo: ");
               scanf("%s",&save);     
  
               if((((out = fopen(save,"w")) == NULL))){
                      system("clear");
                      printf("ERROR");
                      sleep(3000);
                      return;
               }
               else{
       
                    for(x = 0; x < imagem->w; x++)
                        for(y = 0; y < imagem->h; y++)
                            matrizPixel[x][y] = _getpixel(imagem, x, y);
                                                                   
                    for(x = 0; x < imagem->w; x++)
                        for(y = 0; y < imagem->h; y++){
                            matrizRgb[x][y].r = getr(matrizPixel[x][y]);
                            matrizRgb[x][y].g = getg(matrizPixel[x][y]);
                            matrizRgb[x][y].b = getb(matrizPixel[x][y]);
                            fprintf(out,"pix %d, x=%d y=%d, r=%d,g=%d,b=%d\n",matrizPixel[x][y],x,y,matrizPixel[x][y],matrizRgb[x][y].r,matrizRgb[x][y].g,matrizRgb[x][y].b);

                        }

                     for(x = 0; x < imagem->w; x++)
                         for(y = 0; y < imagem->h; y++)
                             putpixel(imagem_gray,x,y,matrizPixel[x][y]);               
                                     
                     fclose(out);
                     system("clear");
                     }
   
    save_bitmap("picture_gray.bmp", imagem_gray, pal);   
    destroy_bitmap(imagem_gray);

    destroy_bitmap(imagem);
    return 0;
}
END_OF_MAIN()


In anex the image and the image gray.

Attachment: picture.bmp
Description: Windows bitmap

Attachment: picture_gray.bmp
Description: Windows bitmap



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/