delphi - Get average color of an image -


i trying average color of image. tried various methods , use following code, not correct result.

can explain wrong code?

  //load bitmap curimg   img1.picture.bitmap := curimg ; //testing previous line    //my image greater 25x25 need 25x25 box    := 0  25   begin     y := 0  25     begin       r := r + getrvalue(curimg.canvas.pixels[y, i]);       g := g + getgvalue(curimg.canvas.pixels[y, i]);       b := b + getbvalue(curimg.canvas.pixels[y, i]);     end;   end;   r := r div (25 * 25);   g := g div (25 * 25);   b := b div (25 * 25);   rgbk := rgb(r, g, b);   result = rgbk; end; 

img1 , image1 of type timagebox on form.

the local variables r,g,b: integer should initialized 0 first.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -