procedure AreaToPix;
var
Handle: THandle;
yFor, xFor: Integer;
bRed, bGreen, bBlue: Byte;
PixelColor: Integer;
bXgesRed, bXgesGreen, bXgesBlue: Integer;
//Duchschnittsfarben Horizontal
bYgesRed, bYgesGreen, bYgesBlue: Integer;
//Duchschnittsfarben Vertikal
begin
Handle := GetDC(0);
try
bXgesBlue := 0;
bXgesGreen := 0;
bXgesRed := 0;
for yFor := 1
to 9
do
begin
bYgesBlue := 0;
bYgesGreen := 0;
bYgesRed := 0;
for xFor := 1
to 7
do
begin
PixelColor := GetPixel(
Handle, round(yFor * ((x2-x1)/9)) + x1, round(xFor * ((y2-y1)/7)) + y1);
bBlue := PixelColor;
bGreen := PixelColor
shr 8;
bRed := PixelColor
shr 16;
bYgesBlue := bYgesBlue + bBlue;
bYgesGreen := bYgesGreen + bGreen;
bYgesRed := bYgesRed + bRed;
end;
bYgesBlue := Round(bYgesBlue / 7);
bYgesGreen := Round(bYgesGreen / 7);
bYgesRed := Round(bYgesRed / 7);
bXgesBlue := bXgesBlue + bYgesBlue;
bXgesGreen := bXgesGreen + bYgesGreen;
bXgesRed := bXgesRed + bYgesRed;
end;
bXgesBlue := Round(bXgesBlue / 9);
bXgesGreen := Round(bXgesGreen / 9);
bXgesRed := Round(bXgesRed / 9);
//Werte ausgeben
u_usbpwm.Form1.changeLEDs(bXgesRed, bXgesGreen, bXgesBlue);
finally
ReleaseDC(0,
Handle);
end;
end;