OK...wie immer...
Schuld war mal wieder das berühmte Pixelformat -> pf24Bit
So sollte es dann stimmen:
Delphi-Quellcode:
procedure ArrangeSymbol(aSource: TBitmap; Width: Integer = -1;Height : Integer = -1;threshold: Byte = 254);
var h,w : integer;
b : ^TRGBTriple;
start, last : TPoint;
buffer : TBitmap;
begin
last.X := 0;
last.Y := 0;
start.X := 1000;
start.Y := 1000;
buffer := TBitmap.Create;
try
buffer.Assign(aSource);
buffer.PixelFormat := pf24Bit;
for h := 0 to buffer.Height -1 do
begin
b := buffer.ScanLine[h];
for w := 0 to buffer.Width -1 do
begin
if (b^.rgbtBlue <= threshold) and (b^.rgbtRed <= threshold) and (b^.rgbtGreen <= threshold) then
begin
if w < start.X then
start.X := w;
if h < start.Y then
start.Y := h;
if w > last.X then
last.X := w;
if h > last.Y then
last.Y := h;
end;
inc(b);
end;
end;
if (Width = -1) or (Height = -1) then
begin
aSource.Width := abs(last.X-start.X)+1;
aSource.Height := abs(last.Y-start.Y)+1;
end
else
begin
aSource.Width := Width;
aSource.Height := Height;
end;
aSource.Canvas.FillRect(aSource.Canvas.ClipRect);
BitBlt(aSource.Canvas.Handle,0,0,aSource.Width,aSource.Height,buffer.Canvas.Handle,start.X,start.Y,SRCCOPY);
finally
buffer.Free;
end;
end;
Philipp F.