hello, i'm trying to steamline some code that paints a image onto a TImage. The
data that is extracted is good, because I can paint the image using
canvas.pixels[x,y] however when I use scanline data, it paints an all white
color even after i stick the color values of the image into the scanline data.
I need help in finding why it does this. You can ignore the api functions and
data such as CtsxColor or tsxSomeFunction, they work just fine.
procedure TtsxMain.bIMPloadImageClick(Sender: TObject);
type
TColorArray = array[0..32767] of TColor;
PColorArray = ^TColorArray;
var
img: tsxImage;
data: PCtsxColorArray;
Row, RowN: PColorArray;
x, y: word;
c: dword;
clr: TColor;
bmp: TBitmap;
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;
Canvas.Brush.Color:= sbIMP.Color;
Picture.Bitmap:= nil;
Canvas.FillRect(imgIMP.BoundsRect);
Refresh;
end;
with imgIMPbw do begin
Left:= 8;
Top:= 8;
Width:= img.width;
Height:= img.height;
Canvas.Brush.Color:= sbIMP.Color;
Picture.Bitmap:= nil;
Canvas.FillRect(imgIMPbw.BoundsRect);
Refresh;
end;
with sbIMP do begin
VertScrollBar.Range:= imgIMP.Width + 8;
HorzScrollBar.Range:= imgIMP.Height + 8;
Refresh;
end;
bmp:= TBitmap.Create;
try
c:= 0;
data:= img.data;
bmp.Width:= imgIMP.Width;
bmp.Height:= imgIMP.Height;
//bmp.Assign(imgIMPbw.Picture.Bitmap);
for y:= 0 to img.height - 1 do begin
Row:= bmp.ScanLine[y];
for x:= 0 to img.width - 1 do begin
Row[x]:= RGB(data[c].red, data[c].green, data[c].blue);
//imgIMP.Canvas.Pixels[x, y]:= clr;
c:= c + 1;
end;
end;
// for some reason the bmp is completely white, i dont know why
// the data is ok, it works when i use canvas.pixels to draw it, but it's
very slow
imgIMP.Picture.Bitmap.Assign(bmp);
imgIMP.Canvas.Draw(0, 0, bmp);
finally
imgIMP.Visible:= (not cbIMPconvertBW.Checked);
imgIMPbw.Visible:= cbIMPconvertBW.Checked;
tsxImageDestroyData(img);
bmp.FreeImage; // could this be a problem?
end;
end;
__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk