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
 Adding a layer from a second image of a dif size
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

AdrianKnowles

USA
35 Posts

Posted - Nov 11 2019 :  12:19:58  Show Profile  Reply
Hi,
I'm wondering what I am missing here

I load 2 images from separate ImageEnFolderMView's. Both images have the same original pixel dimensions)
Image1 is the large image on the left of the pictures
Image 2 is smaller (Top right on the pictures)

I copy the second image as a layer on the first image. I then change the opacity via the scrollbar. This works very well.





However if the second image is a different size then the following happens on copying Image2 to Image1



As you change the opacity you can see the both images are now shifted X & Y and the second image is actually cropped




The code is very simple
****
if OpacitySelectionRadiogroup.ItemIndex = 0 then
begin
// showmessage('First one (0)');
LargeViewport.LayersAdd(); // Append a new layer
LargeViewport.IO.LoadFromFile(ImageEnFolderMView4.ImageFileName[ImageEnFolderMView4.SelectedImage]);
LargeViewport.Update();
end
****

I tried both LargeViewport.LayersRepositionAll(0,0) which didn't seem to do anything and trying to reposition the layers separately, (LargeViewport.Layers[1].PosX :=0;)

I'm probably missing something very simple so any advice gratefully received.

I include the 2 images (DICOM)




attach/AdrianKnowles/20191111121742_Image1.zip
307.21 KB

attach/AdrianKnowles/20191111121843_Image2.zip
458.15 KB

Thanks,
Adrian

xequte

38610 Posts

Posted - Nov 11 2019 :  19:45:21  Show Profile  Reply
Hi Adrian

Are you just trying to make the layer the same size as the image?

How about:

LargeViewport.LayersAdd(); // Append a new layer
LargeViewport.IO.LoadFromFile(ImageEnFolderMView4.ImageFileName[ImageEnFolderMView4.SelectedImage]);
LargeViewport.CurrentLayer.PosX := LargeViewport.ViewX;
LargeViewport.CurrentLayer.PosY := LargeViewport.ViewY;
LargeViewport.CurrentLayer.Width := LargeViewport.IEBitmap.Width;
LargeViewport.CurrentLayer.Height := LargeViewport.IEBitmap.Height;

LargeViewport.Update();

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

AdrianKnowles

USA
35 Posts

Posted - Nov 12 2019 :  00:39:08  Show Profile  Reply
Hi, yes that correct. I tried the code you provided and I get the results in the first column.

I also tried the following with same results as column 1

LargeViewport.LayersAdd(); // Append a new layer LargeViewport.IO.LoadFromFile(ImageEnFolderMView4.ImageFileName[ImageEnFolderMView4.SelectedImage]);
LargeViewport.CurrentLayer.PosX := 0;
LargeViewport.CurrentLayer.Posy := 0;
LargeViewport.layers[0].Posx := 0;
LargeViewport.layers[0].Posy := 0;


I then subtracted 28 from the layer[1] (currentlayer) X & Y (x-28 and y-28). I wanted to see if it would shift the image or throw an error (<0). I got to subtracting -28 by trial and error.
Visually I got the results that are in the second column.

I then subtracted from both sets of coords to get the 3rd column

The code I used for experiment 3 is

LargeViewport.LayersAdd(); // Append a new layer LargeViewport.IO.LoadFromFile(ImageEnFolderMView4.ImageFileName[ImageEnFolderMView4.SelectedImage]);
LargeViewport.CurrentLayer.PosX := -28;
LargeViewport.CurrentLayer.Posy := -28;
LargeViewport.layers[0].Posx := -28;
LargeViewport.layers[0].Posy := -28;





Kind regards,
Adrian
Go to Top of Page

xequte

38610 Posts

Posted - Nov 12 2019 :  18:14:23  Show Profile  Reply
Hi Adrian

You should not need to use magic numbers, and I cannot see why -28 would work.

How about...

LargeViewport.LayersAdd(); // Append a new layer
LargeViewport.IO.LoadFromFile(ImageEnFolderMView4.ImageFileName[ImageEnFolderMView4.SelectedImage]);
LargeViewport.CurrentLayer.PosX := LargeViewport.Layers[0].PosX;
LargeViewport.CurrentLayer.PosY := LargeViewport.Layers[0].PosY;
LargeViewport.CurrentLayer.Width := LargeViewport.Layers[0].Width;
LargeViewport.CurrentLayer.Height := LargeViewport.Layers[0].Height;
LargeViewport.Update();


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

AdrianKnowles

USA
35 Posts

Posted - Nov 12 2019 :  19:55:55  Show Profile  Reply
Hi Nigel,
Many thanks for your help, that did the trick!
Kind regards,
Adrian
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: