Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {*
- Brightens the image or darkens if negative "amount" is given.
- *}
- function ImBrighten(ImgArr:T2DIntArray; Amount:Extended; Legacy:Boolean): T2DIntArray; StdCall;
- var
- W,H,x,y,R,G,B,AmountL:Integer;
- cH,cS,cV:Extended;
- begin
- W := Length(ImgArr[0]);
- H := Length(ImgArr);
- SetLength(Result, H,W);
- Dec(W);
- Dec(H);
- case Legacy of
- False:
- for y:=0 to H do
- for x:=0 to W do
- begin
- ColorToHSV(ImgArr[y][x], cH,cS,cV);
- cV := cV+Amount;
- if (cV < 0.0) then cV := 0
- else if (cV > 1.0) then cV := 1.0;
- HSVToRGB(cH,cS,cV, R,G,B);
- Result[y][x] := (R) or (G shl 8) or (B shl 16);
- end;
- True:
- begin
- AmountL := Round(Amount);
- for y:=0 to H do
- for x:=0 to W do
- begin
- ColorToRGB2(ImgArr[y][x], R,G,B);
- R := R + AmountL;
- if (R > 255) then R:=255
- else if (R < 0) then R:=0;
- G := G + AmountL;
- if (G > 255) then G:=255
- else if (G < 0) then G:=0;
- B := B + AmountL;
- if (B > 255) then B:=255
- else if (B < 0) then B:=0;
- Result[y][x] := (R) or (G shl 8) or (B shl 16);
- end;
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement