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
 Most effeceient way to split an image in two parts
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
730 Posts

Posted - Oct 15 2013 :  08:23:00  Show Profile  Reply
Hello,

I am trying to Load an image which is very bulky (around 150 MB) and the split it (horizontally or vertically) into two parts.

Currently I am loading the image, and then cropping it by using Crop. After this I save the file to a different name. Then I reload the image and then Crop it again from the other part.

This process at times seems to take ages, esp. with large images.

Another thing I would like to know if there is any way by which one can split an image (horizontally or vertically) using percentage like in ImageMagick.

TIA



Yogi Yang

w2m

USA
1990 Posts

Posted - Oct 15 2013 :  11:46:47  Show Profile  Reply
A 150 MB image is quite large, so the only way you may be able to speed it up is to do your processing in a thread. It will still take some time to process the file, but at least the GUI will continue to operate while the work is done in the background thread.

What are the dimensions of the image?

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

yogiyang

India
730 Posts

Posted - Oct 16 2013 :  03:46:06  Show Profile  Reply
The dimension of large images is around 14400 X 4800 pixels at 200 DPI. Sometimes images can be at 300 DPI also! These images are generally created/assembled in Photoshop.

I would like to repeat a part of my question: Is there any way by which one can split an image (horizontally or vertically) using percentage like in ImageMagick.

I was wondering if there is a way to open partial image instead of full image....

I have observed that ImageMagick is very fast in cropping I don't know as to how though. ):

TIA



Yogi Yang
Go to Top of Page

xequte

39108 Posts

Posted - Oct 16 2013 :  21:00:36  Show Profile  Reply
Hi

> Is there any way by which one can split an image (horizontally or vertically) using percentage.

I assume you mean copy the left part of an image, for example, from the point (0 x 0) to (desired width x height).

In that case it would only be a simple matter of using:

DestBitmap.Canvas.CopyRect(Rect(0,0,iWidth,SourceBitmap.height), SourceBitmap.Canvas, Rect(0,0,iWidth,SourceBitmap.height));


Where iWidth is MulDiv(SourceBitmap.Width, iDesiredPercentage, 100);

Also assumes you have set DestBitmap size correctly.

Is that what you are trying to do? You could use two TIEBitmaps if you need to loading and saving support.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

yogiyang

India
730 Posts

Posted - Oct 23 2013 :  22:57:17  Show Profile  Reply
No not to copy to another control.

What I want to do is Load a file in ImageEn and then crop if either from Left or Top by exactly 50% (eg. width is 2000 px then it should split at 1000 px) and then save the image under a new name. Again reload the original image and crop it from Right or Bottom and again save the image under a new name.

Regards,

Yogi Yang


Yogi Yang
Go to Top of Page

xequte

39108 Posts

Posted - Oct 24 2013 :  01:06:10  Show Profile  Reply
Your method is OK then, but it should be faster if you do not load the image twice. Try it this way:

1. Load the image into ImageEn
2. Create a second bitmap
3. Copy the desired portion of the image into the bitmap
4. Crop the remaining image in ImageEn
5. Save the image in the bitmap
6. Save the image in ImageEn


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

yogiyang

India
730 Posts

Posted - Oct 31 2013 :  05:54:46  Show Profile  Reply
I am thinking on another line:

1. Load Image in ImageEn
2. Set Undos to 10
3. Save Undo
4. Crop the image (from Left to Middle)
5. Save Image to a file
6. Undo
7. Crop the image (from Middle to Right)
8. Save Image to a file

What do you say? Is this method advisable or not?

TIA




Yogi Yang
Go to Top of Page

xequte

39108 Posts

Posted - Nov 01 2013 :  13:22:33  Show Profile  Reply
Hi Yogi

That will work OK, but it does mean holding extra images in memory.

How about:

1. Create three TIEBitmaps
2. Load the image into the first TIEBitmap
3. Use CopyRectTo to output the left portion to the second TIEBitmap, and the right portion to the third TIEBitmap

http://www.imageen.com/help/TIEBitmap.CopyRectTo.html

4. Save the second and third TIEBitmaps


That should be the fastest method

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

yogiyang

India
730 Posts

Posted - Nov 02 2013 :  07:47:53  Show Profile  Reply
Hi,

Thanks for your tip. I will try that also and see which is better for me to use.

Regards,




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