Hello, could someone please tell me why I get green scan lines covering the
image in my result bmp (imgIMPbw)? I have tried doing this pixel by pixel
and it still gives me problems (width and height get 0'd and I get a
scanline index out of range error) if I use a larger image than 64x64..
procedure tsxEventCB(cbtype: tsxEventCallbackType; data: pointer); cdecl;
type
TRGB = record
r, g, b: byte;
end;
TColorArray = array[0..32767] of TRGB;
PColorArray = ^TColorArray;
function RGBToGray(src: TRGB): TRGB;
var
gs: Byte;
begin
gs:= Round(src.r * 0.299 +
src.g * 0.587 +
src.b * 0.114);
Result.r:= gs;
Result.g:= gs;
Result.b:= gs;
end;
var
idata: PtsxEventPluginImageBrowserData;
data1, data2: PColorArray;
x, y, w, h: smallint;
bmp: TBitmap;
begin
case cbtype of
e_tsxECT_PLUGINIMAGEBROWSER: begin
idata:= data;
tsxMain.leIMPimageName.Text:= idata^.afile;
tsxMain.imgIMP.Picture.LoadFromFile(idata^.afile); \\ loads just fine
bmp:= TBitmap.Create;
try
w:= tsxMain.imgIMP.Picture.Bitmap.Width;
h:= tsxMain.imgIMP.Picture.Bitmap.Height;
bmp.Width:= w;
bmp.Height:= h;
bmp.Assign(tsxMain.imgIMP.Picture.Bitmap);
for y:= 0 to h - 1 do begin
data1:= bmp.ScanLine[y];
data2:= tsxMain.imgIMP.Picture.Bitmap.ScanLine[y];
for x:= 0 to w - 1 do
data1[x]:= RGBToGray(data2[x]);
end;
tsxMain.imgIMPbw.Picture.Bitmap:= bmp;
finally
bmp.FreeImage;
bmp.Free;
end;
end;
end;
end;
__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk