hello, I recently found image loading source code and it works great (for
loading, doesnt save). It's called GraphicEx and you can download it at
http://www.lischke-online.de/
However I've come into a problem with using scanline on some images and I'm
not sure if it's related to GraphicsEx. In fact I think it's a bug in Delphi
or my usual stupidity. I'm converting the loaded graphic into a greyscale
image. This works fine for small images, however on larger images it either
causes the last function to generate acess violation or it will say that
scanline index out of range. So i checked and found that it generated this
error on the first index (0) and also that the graphic.empty returned true.
Is this a bug or am I doing something wrong?
procedure TtsxMain.bIMPloadImageClick(Sender: TObject);
type
TColorArray = array[0..32767] of TColor;
PColorArray = ^TColorArray;
var
img: tsxImage;
Row: PColorArray;
x, y: Word;
begin
if (not OpenDialog1.Execute) then
exit;
leIMPimageName.Text:= OpenDialog1.FileName;
tsxImageLoadData(img, PChar(OpenDialog1.FileName));
SetActiveWindow(sbIMP.Handle);
with imgIMP do begin
Left:= 8;
Top:= 8;
Width:= img.width;
Height:= img.height;
Picture.Bitmap:= nil;
Canvas.Brush.Color:= sbIMP.Color;
Canvas.FillRect(imgIMP.BoundsRect);
Refresh;
end;
with imgIMPbw do begin
Left:= 8;
Top:= 8;
Width:= img.width;
Height:= img.height;
Picture.Bitmap:= nil;
Canvas.Brush.Color:= sbIMP.Color;
Canvas.FillRect(imgIMPbw.BoundsRect);
Refresh;
end;
with sbIMP do begin
VertScrollBar.Range:= imgIMP.Height + 18;
HorzScrollBar.Range:= imgIMP.Width + 18;
Refresh;
end;
try
imgIMP.Picture.LoadFromFile(leIMPimageName.Text);
imgIMPbw.Picture.Assign(imgIMP.Picture);
for y:= 0 to img.Height - 1 do begin
Row:= imgIMPbw.Picture.Bitmap.ScanLine[y];
for x:= 0 to img.Width - 1 do
Row[x]:= ClrToBW(Row[x]);
end;
finally
imgIMP.Visible:= (not cbIMPconvertBW.Checked);
imgIMPbw.Visible:= cbIMPconvertBW.Checked;
tsxImageDestroyData(img);
end;
end;
----- Original Message -----
From: Richard R
To: 'Delphi-Talk Discussion List'
Sent: Monday, October 03, 2005 10:49 AM
Subject: using scanline to render a image
hello, i'm trying to steamline some code that paints a image onto a TImage.
...
__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk