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
Post a Comment