Contact us


All times are UTC - 8 hours



   [ 4 posts ] 
Author Message
   


Joined: Thu Jun 25, 2015 7:45 pm
Posts: 7
I use "LoadImageEx" to load images from local file system:
Code:
  DWObject.IfShowFileDialog = true;
  DWObject.LoadImageEx("", EnumDWT_ImageType.IT_ALL, onImport, function() {});

In the "onImport" callback function, I get the base64 data as the following code:
Code:
  var importNumber = DWObject.HowManyImagesInBuffer;
  for(var loop = 0; loop < importNumber; loop++) {
     DWObject.CurrentImageIndexInBuffer = loop;
     DWObject.GetSelectedImagesSize();
     var imageData = DWObject.SaveSelectedImagesToBase64Binary();
  }

Because we have our own viewer, so we need get the format of selected image to add extra info like:
data:image/png;base64,"/9j/4AAQSkZJRgABA..."
Also we have a requirement to save image into user defined local file system, so we also need that informatoin to call SaveAsBMP, SaveAsPDF.

Any help would be appreciated. Thanks!


User avatar
   


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1706
Hi Roman,

Thanks for contacting Dynamsoft support team.

Regarding your code, there is a missing parameter in GetSelectedImagesSize(), the selected image type is required to be passed in the method.

You can use following code to generate the base 64 string for the imported image:

Code:
var newImage = document.createElement('img');
    newImage.onload = function () {
        document.getElementsByTagName('body')[0].appendChild(this);
    };
    newImage.src = "data:image/png;base64," + imagedata;

For more information, please refer to SaveSelectedImagesToBase64Binary() API.

Regards,

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


   


Joined: Thu Jun 25, 2015 7:45 pm
Posts: 7
Vincy wrote:
Hi Roman,

Thanks for contacting Dynamsoft support team.

Regarding your code, there is a missing parameter in GetSelectedImagesSize(), the selected image type is required to be passed in the method.

You can use following code to generate the base 64 string for the imported image:

Code:
var newImage = document.createElement('img');
    newImage.onload = function () {
        document.getElementsByTagName('body')[0].appendChild(this);
    };
    newImage.src = "data:image/png;base64," + imagedata;

For more information, please refer to SaveSelectedImagesToBase64Binary() API.

Regards,

Hi Vincy,

Thanks for your response.
Quote:
Regarding your code, there is a missing parameter in GetSelectedImagesSize(), the selected image type is required to be passed in the method.

But how can I know which type of image the dynamsoft web twain loaded? Because those images are seleced by user via File Selection Dialog.


User avatar
   


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1706
Hi Roman,

It’s my pleasure.

Regarding the image type, OnGetFilePath event may help. You can use it together with ShowFileDialog() method.

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Display posts from previous:  Sort by  
   [ 4 posts ] 


Who is online

Users browsing this forum: cheaptomswl, WillieCam 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 © 2018 Dynamsoft | All Rights Reserved
dynamic designed by Dynamsoft team
Fatal: Not able to open ./cache/data_global.php