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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 BackBuffer drawing...

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
rmklever Posted - Jan 22 2020 : 17:12:29
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
5   L A T E S T    R E P L I E S    (Newest First)
srtt Posted - Feb 20 2024 : 06:03:53
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));

xequte Posted - Feb 19 2024 : 22:24:50
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
srtt Posted - Feb 19 2024 : 12:48:31
Did you find a solution to the code
I have that same problem.
rmklever Posted - Jan 27 2020 : 15:30:08
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
xequte Posted - Jan 26 2020 : 21:55:58
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