Contact us


All times are UTC - 8 hours



Post new topic Reply to topic  [ 11 posts ] 
Author Message
Offline Profile  


Joined: Mon Jan 16, 2017 2:30 am
Posts: 8
Hello,

I want to add a button to my Windows App that gets selected area as a new image, I tried using crop or cut but I'm not sure how to do it...

Thank you for your help!


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1691
Hi RoshnaOmer,

Thanks for the information.

Please check cropPicture() function in our demo(C:\Program Files (x86)\Dynamsoft\Dynamic .NET TWAIN 7.0\Samples\C# Samples\DotNETTWAINDemo).

Regards,

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Mon Jan 16, 2017 2:30 am
Posts: 8
Hi!
Yes I have used that function for normal cropping, but what I want is the old image to remain in its index and a new image to be added to my buffer that is the cropped image

example:

I have scanned 2 drivers licenses and I want to crop each as a new image and then delete the one where there are two...

Thanks...


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1691
Hi RoshnaOmer,

Thanks for the information.

Please check if CropToClipboard meets your need. To add it to the buffer, please use LoadDibFromClipboard.

Regards,

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Mon Jan 16, 2017 2:30 am
Posts: 8
Hi, thank you for the reply...

I an using it this way but the image in the twain changes immediately when using crop to clipboard... how can I fix it?

Code:
 void CropToNew(int imageIndex, Rectangle rc)
        {
            dynamicDotNetTwain1.CropToClipboard((short)imageIndex, rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height);
            short currentIndex = ++dynamicDotNetTwain1.CurrentImageIndexInBuffer;
            dynamicDotNetTwain1.CurrentImageIndexInBuffer = currentIndex;
            dynamicDotNetTwain1.LoadDibFromClipboard();
        }


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1691
Hi RoshnaOmer,

Thanks for the update.

Please have a test with the following codes:
Code:
dynamicDotNetTwain.CopyToClipboard(dynamicDotNetTwain.CurrentImageIndexInBuffer);
            dynamicDotNetTwain.LoadDibFromClipboard();
            dynamicDotNetTwain.Crop((short)imageIndex, rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height);


Regards,

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Mon Jan 16, 2017 2:30 am
Posts: 8
Thank you for the reply!
the copytoclipboard gave me an idea to save the original image manually and retrieve it, but I have a problem with adding the not cropped image in a new index, can you help please?

Code:
void CropToNew1(int imageIndex, Rectangle rc)
        {
            short i = short.Parse(imageIndex.ToString());
            Directory.CreateDirectory("MyPath");
            string initDirectory = (Path.GetDirectoryName("MyPath";
            dynamicDotNetTwain1.SaveAsJPEG(initDirectory, i);
            dynamicDotNetTwain1.Crop((short)imageIndex, rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height);
            //the image to be loaded as a new image (with different index)
            dynamicDotNetTwain1.LoadImage(initDirectory);
        }


Offline Profile  


Joined: Mon Jan 16, 2017 2:30 am
Posts: 8
Hi!
This is how I fixed it, I still have one problem, as I save my original file as jpg the file size reduces drastically, what file type should I use to get the least amount of compression?


Code:
        void CropToNew1(int imageIndex, Rectangle rc)
        {
            Directory.CreateDirectory("MyPath");
           
            string myDirectory = ("MyPath");
            foreach (string fileName in filetoDelete)
            {
                File.Delete(fileName);
            }
            short i = short.Parse(imageIndex.ToString());
            string initDirectory = "MyPath + File Name.jpg";
            string CroppedDirectory = "MyPath + File Name_Cropped.jpg";
            dynamicDotNetTwain1.SaveAsJPEG(initDirectory, i);

            dynamicDotNetTwain1.Crop((short)imageIndex, rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height);
            dynamicDotNetTwain1.SaveAsJPEG(CroppedDirectory, i);

            dynamicDotNetTwain1.RemoveImage(dynamicDotNetTwain1.CurrentImageIndexInBuffer);
            string[] fileEntries = Directory.GetFiles(myDirectory);
            foreach (string fileName in fileEntries)
            {
                dynamicDotNetTwain1.LoadImage(fileName);
            }
            checkImageCount();
        }


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1691
Hi RoshnaOmer,

Thanks for the update.

Please try BMP instead.

Regards,

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Mon Jan 16, 2017 2:30 am
Posts: 8
I will, Thank you so much for all the help!


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1691
My pleasure.

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ]  Moderators: Michael, Vincy


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Copyright © 2016 Dynamsoft | All Rights Reserved
dynamic designed by Dynamsoft team