mirror of
https://github.com/moparisthebest/Simba
synced 2025-02-11 21:00:13 -05:00
Fix for bitmaps, Posterize. Given a high enough (Po) value, the function would
throw away data and deliver incorrect results. git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@280 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
cd2ba7e3cb
commit
6e3606466b
@ -741,9 +741,9 @@ begin
|
|||||||
PtrNew := TargetBitmap.FData;
|
PtrNew := TargetBitmap.FData;
|
||||||
for i := (h*w-1) downto 0 do
|
for i := (h*w-1) downto 0 do
|
||||||
begin;
|
begin;
|
||||||
PtrNew^.r := Round(PtrOld^.r / po) * Po;
|
PtrNew^.r := min(Round(PtrOld^.r / po) * Po, 255);
|
||||||
PtrNew^.g := Round(PtrOld^.g / po) * Po;
|
PtrNew^.g := min(Round(PtrOld^.g / po) * Po, 255);
|
||||||
PtrNew^.b := Round(PtrOld^.b / po) * Po;
|
PtrNew^.b := min(Round(PtrOld^.b / po) * Po, 255);
|
||||||
inc(ptrOld);
|
inc(ptrOld);
|
||||||
inc(PtrNew);
|
inc(PtrNew);
|
||||||
end;
|
end;
|
||||||
@ -753,15 +753,25 @@ procedure TMufasaBitmap.Posterize(Po: integer);
|
|||||||
var
|
var
|
||||||
I : integer;
|
I : integer;
|
||||||
Ptr: PRGB32;
|
Ptr: PRGB32;
|
||||||
|
{a:integer; }
|
||||||
begin
|
begin
|
||||||
if not InRange(Po,1,255) then
|
if not InRange(Po,1,255) then
|
||||||
Raise exception.CreateFmt('Posterize Po(%d) out of range[1,255]',[Po]);
|
Raise exception.CreateFmt('Posterize Po(%d) out of range[1,255]',[Po]);
|
||||||
Ptr := Self.FData;
|
Ptr := Self.FData;
|
||||||
for i := (h*w-1) downto 0 do
|
for i := (h*w-1) downto 0 do
|
||||||
begin;
|
begin;
|
||||||
ptr^.r := Round(ptr^.r / po) * Po;
|
{ a := round(ptr^.r / po);
|
||||||
ptr^.g := Round(ptr^.g / po) * Po;
|
a := a * po;
|
||||||
ptr^.b := Round(ptr^.b / po) * Po;
|
ptr^.r := min(a,255);
|
||||||
|
a := round(ptr^.g / po);
|
||||||
|
a := a * po;
|
||||||
|
ptr^.g := min(a,255);
|
||||||
|
a := round(ptr^.b / po);
|
||||||
|
a := a * po;
|
||||||
|
ptr^.b := min(a,255); }
|
||||||
|
ptr^.r := min(Round(ptr^.r / po) * Po, 255);
|
||||||
|
ptr^.g := min(Round(ptr^.g / po) * Po, 255);
|
||||||
|
ptr^.b := min(Round(ptr^.b / po) * Po, 255);
|
||||||
inc(ptr);
|
inc(ptr);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -87,6 +87,8 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{ TODO: add cts per colour/tolerance? }
|
{ TODO: add cts per colour/tolerance? }
|
||||||
|
|
||||||
|
// TODO DTM-Not points. Not very hard really.
|
||||||
pDTM = record
|
pDTM = record
|
||||||
l: Integer;
|
l: Integer;
|
||||||
p: TPointArray;
|
p: TPointArray;
|
||||||
|
Loading…
Reference in New Issue
Block a user