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
 Adding a layer from a second image of a dif size

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
AdrianKnowles Posted - Nov 11 2019 : 12:19:58
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
4   L A T E S T    R E P L I E S    (Newest First)
AdrianKnowles Posted - Nov 12 2019 : 19:55:55
Hi Nigel,
Many thanks for your help, that did the trick!
Kind regards,
Adrian
xequte Posted - Nov 12 2019 : 18:14:23
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
AdrianKnowles Posted - Nov 12 2019 : 00:39:08
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
xequte Posted - Nov 11 2019 : 19:45:21
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