Hi,
I am making a split view to show before and after effect changes. To do this I am applying the effect into the ImageEnView.IEBitmap and then copy a part of the original image into the BackBuffer in the DrawBackBuffer event. The problem is that these parts do not line up so I get a mismatch which is very annoying when you compare left and right side...
How can I make sure these images line up...
Here is how I do it now...
procedure TfrmMain.imgViewDrawBackBuffer(Sender: TObject);
type
PRGBArr = ^TRGBArr;
TRGBArr = array[0..32768] of TRGB;
const
cMagenta: TRGB = (b: 255; g: 0;r: 255);
cWhite: TRGB = (b: 255; g: 255;r: 255);
var
rx, ry, rw, rh, sx, sy, sw, sh: Integer;
y, x, i, j, w, h: Integer;
SL: PRGBArr;
Color: TRGB;
begin
if chkSplit.Checked then begin
imgView.GetRenderRectangles(rx, ry, rw, rh, sx, sy, sw, sh);
// Position splitter in the middle of the view when activated
if SplitPos = -1 then SplitPos:= (sw shr 1) + sx;
if (Dirty) or (rw <> SplitBmp.Width) then begin
SplitBmp.PixelFormat:= pf24Bit;
SplitBmp.SetSize(rw, rh);
GfxBmp.RenderToTBitmapEx(SplitBmp, 0, 0, rw - 1, rh - 1, sx, sy, sw, sh, 255, rfNone);
Dirty:= False;
end;
x:= imgView.XBmp2Scr(SplitPos); // Get splitter x position
// Copy part of original image to the right side of the splitter
if ImgLoaded then imgView.BackBuffer.Canvas.CopyRect(Rect(x, ry, rx + rw, ry +
SplitBmp.Height), SplitBmp.Canvas, Rect(x - rx, 0, SplitBmp.Width, SplitBmp.Height));
// Draw splitter
if (x > 0) and (x < imgView.ClientWidth) then begin
i:= 1;
Color:= cMagenta;
for y:= 0 to imgView.ClientHeight - 1 do begin
SL:= imgView.BackBuffer.ScanLine[y];
if y mod 4 = 0 then begin
i:= -i;
if i = -1 then Color:= cMagenta else Color:= cWhite;
end;
SL[x]:= Color;
end;
end;
end;
end;
Roy M Klever
Klever on Delphi - www.rmklever.com