Image problem (ImageEdit.dll)

ExcludeReality

Active Member
Licensed User
I have a small problem with the ImageEdit library.
I'm not really used to working with image libraries, so my question might have a simple answer.

I have a picture (1024 x 768) which is set as background for a form (320 x 240).
I have calculated that the original image is 3,2 times bigger then it is when adjusted to the form size.

Then when I try to crop the image (Part of the right side), It "croppes" (Is that even a word?) from the original image, instead of the form image.

Therefore, I crop the wrong area (3,2 pixels wrong to be exact).

My code:
B4X:
   ImageEdit.LoadImage (Form1.Image)
   ImageEdit.Crop (140,0,240,240)
   SideBar.Image = ImageEdit.GetImage ("C")

This does not work either
B4X:
        Bitmap.New1 (AppPath & "\1.bmp") 'The original image
   ImageEdit.LoadImage (Bitmap.value)
   ImageEdit.Crop (140,0,240,240)
   SideBar.Image = ImageEdit.GetImage ("C")

And finally, the most mathematically correct (?)

B4X:
        Bitmap.New1 (AppPath & "\1.bmp") 'The original image
   ImageEdit.LoadImage (Bitmap.value)
   ImageEdit.Crop (140 / 3.2,0,240 / 3.2,240 / 3.2) 'Split each value by 3,2
   SideBar.Image = ImageEdit.GetImage ("C")

I'm probably just too blind to see the answer :)
 

agraham

Expert
Licensed User
Longtime User
ImageEdit is probably the wrong library for this. Using ImagLib or ImageLibEx is probably better.

However

ImageEdit.Crop (140,0,240,240)
will give you a resultant image of size 100 x 240 pixels which I suspect is not what you want.

ImageEdit.Crop (0,0,239,319)
will give you 240 x 320 pixels from the top left of the image.

ImageEdit.Crop (784,448,1023,767)
will give you 240 x 320 pixels from the bottom right of the image.

Note that the displayed area of a Form on a device is actually 240 x 268 pixels.
 

ExcludeReality

Active Member
Licensed User
The reason I use ImageEdit is because I will adjust the brightness of the cropped image, however that part works perfect so I excluded it from my code example.

But on the subject;
A 100 x 240 pixels rectangle IS in fact what I want.
BUT, I want to crop it from the picture that has been adjusted to the form size, not the original (1024 x 768) picture.
 

agraham

Expert
Licensed User
Longtime User
I want to crop it from the picture that has been adjusted to the form size
Why haven't you resized it first then?
B4X:
   ImageEdit.LoadImage (Form1.Image)
   [COLOR="Red"]ImageEdit.Resize(320,240)[/COLOR]
   ImageEdit.Crop (140,0,240,240)
   SideBar.Image = ImageEdit.GetImage ("C")
 
Top