ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 BackBuffer drawing...
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

rmklever

Norway
51 Posts

Posted - Jan 22 2020 :  17:12:29  Show Profile  Reply
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

xequte

38176 Posts

Posted - Jan 26 2020 :  21:55:58  Show Profile  Reply
Hi Roy

I'm sorry, it's hard for me to read other people's code. Can you explain what you are seeing when you use the code?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

rmklever

Norway
51 Posts

Posted - Jan 27 2020 :  15:30:08  Show Profile  Reply
Hi Nigel

attach/rmklever/20201271551_IESplitPreview.zip
2329.1 KB

I included a zip file with code and exe. I hope that helps...

What I am doing is as follow.

I load a image into the ImageenView and make a copy of its IEBitmap then I do a negative filter to the ImageenView.

I am also using a third image as a chache of the BackBuffer. If this image needs to be updated I set Dirty to True

Well I actually using the info from the GetRenderRectangle to make a copy from the IEBitmap copy I took when loading the image a copy of the original (without the negative effect).

This image should be same size as the Backbuffer and I should be able to copy the part on the right side of the slider into the BackBuffer so I can have a After/Before filter preview. My idea was that since these images are the same size it should be easy to just copy a part of it to the other without any glitches... but it is not working correctly...
At 100% zoom it is working but other scales get glitches...



To the left of the slider a preview of the negative filter is shown to the right a view of the original image is shown.

I have to use a cache image because large images (6000x4000) is not scaled fast enough.

Roy M Klever
Klever on Delphi - www.rmklever.com
Go to Top of Page

srtt

Turkey
17 Posts

Posted - Feb 19 2024 :  12:48:31  Show Profile  Reply
Did you find a solution to the code
I have that same problem.
Go to Top of Page

xequte

38176 Posts

Posted - Feb 19 2024 :  22:24:50  Show Profile  Reply
Hi Roy

Sorry, I'm not sure why this did not get followed up on. We have a demo that does this now. You can email us for the source code.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

srtt

Turkey
17 Posts

Posted - Feb 20 2024 :  06:03:53  Show Profile  Reply
I think there is a bug in the imgview, procedure in the code above.
imgView.BackBuffer.Canvas.CopyRect(Rect(x, ry, rx + rw, ry + SplitBmp.Height), SplitBmp.Canvas, Rect(x - rx, 0, SplitBmp.Width, SplitBmp.Height));

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: