Get the string invalid Base64 of image of toDataURL() for the first time in 10 of blackberry webworks

Hello

I need to get the Contact image converted to string Base64 using BB 10 Webworks (blackberry.pim.contacts) I get only the contact.photos [0] .smallFilePath which returns the path to the phonebook file.

Now, I want to get the image of this path and convert it to a Base64 string.

Here's the javascript code :

var img = document.createElement ('Image');
var canvas = document.createElement ('Canvas');

function getBase64Image (p) {}
img.setAttribute ("src", p);

Img.width = Canvas.Width;

Canvas.height = img.height;

CTX var = canvas.getContext ("2d");
ctx.drawImage (img, 0, 0);
Return canvas.toDataURL("image/jpg");

}

This means bad Base64 string of image for the first time. When I convert this string to the image it displays white screen. But returns a string in the Mithraeum and after conversion, display a correct image.

I use Blackberry Z10 (OS 10) for the test.

I think that the canvas is not drawing image properly for the first time.

I have searched and tried many things, but not got success. What will be the solution.

Thanks in advance.

My guess is that the image did not load the source completely still. Setting the src / image loading is an asynchronous event, which means that your code will continue to the next line regardless of whether the image has loaded yet or not.

After calling setAttribute instead of execute the code of the Web, you will probably need define an event on img for the load event listener. Once the image is loaded, you can then use the img with canvas variable to retrieve its data.

Note that getBase64 will return immediately, so you may need to develop some sort of mechanism to wait before returning, or the asynchronous approach and integrate reminders for the success trigger the next piece of code.

Tags: BlackBerry Developers

Similar Questions

  • How to add two lines when the second row is not visible, but also gets the first data line too?

    Mr President

    Jdev worm is 12.2.1

    How to add two lines when the second row is not visible, but also gets the first data line too?

    I want to add two lines like below picture, but want the second to remain invisible.

    tworows.png

    I asked this question but my way of asking was wrong, that's why for me once again.

    Concerning

    Try to follow these steps:

    1. in the database table to add the new column "JOIN_COLUMN" and add the new sequence "JOIN_SEQ".

    2. Add this new column in the entity object. (You can add this in entity object by right clicking on the entity object and then select "Synchronize with database" then the new column and press on sync)

    3. in your bookmark create button to create only one line NOT 2 rows.

    4 - Open the object entity--> java--> java class--> on the entity object class generate and Tick tick on the accessors and methods of data manipulation

    5 - Open the generated class to EntityImpl and go to the doDML method and write this code

      protected void doDML(int operation, TransactionEvent e)
      {
        if(operation == DML_INSERT)
        {
          SequenceImpl seq = new SequenceImpl("JOIN_SEQ", getDBTransaction());
          oracle.jbo.domain.Number seqValue = seq.getSequenceNumber();
          setJoinColumn(seqValue);
          insertSecondRowInDatabase(getAttribute1(), getAttribute2(), getAttribute3(), getJoinColumn());
        }
    
        if(operation == DML_UPDATE)
        {
          updateSecondRowInDatabase(getAttribute1(), getAttribute2(), getAttribute3(), getJoinColumn());
        }
    
        super.doDML(operation, e);
      }
    
      private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object joinColumn)
      {
        PreparedStatement stat = null;
        try
        {
          String sql = "Insert into table_name (COLUMN_1,COLUMN_2,COLUMN_3,JOIN_COLUMN, HIDDEN_COLUMN) values ('" + value1 + "','" + value2 + "','" + value3 + "','" + joinColumn + "', 1)";
          stat = getDBTransaction().createPreparedStatement(sql, 1);
          stat.executeUpdate();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        finally
        {
          try
          {
            stat.close();
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
      }
    
      private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object joinColumn)
      {
        PreparedStatement stat = null;
        try
        {
          String sql = "update table_name set column_1='" + value1 + "', column_2='" + value2 + "', column_3='" + value3 + "' where JOIN_COLUMN='" + joinColumn + "'";
          stat = getDBTransaction().createPreparedStatement(sql, 1);
          stat.executeUpdate();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        finally
        {
          try
          {
            stat.close();
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
      }
    
  • I try to add an image map for the first time using Dreamweaver CC

    I am trying to add an image map for the first time using Dreamweaver CC in an html site.

    I can get map controls is displayed when I select the image in the code, and I can select the rectangle tool.

    However, when I try to select the area of the image disappears from the section of the map of the properties viewer and I can't select the area for my hyperlink.

    What I am I missing videos online are it seems so simple, but something with my page is not allowing me to withdraw this.

    This is the code section and the image that I'm trying to add the link.

    < side class = "sidebar" >

    < img src = "images/flowchart.jpg" alt ="product dev. Flowchart">

    < / side >

    Please help or give me any advice... There might be something to do with the fact that my site is "sensitive"?

    Hello

    You could just add links to each box, but a better solution would be to use svg for this. Unfortunately, it is easier for me to write for someone who does not know svg to do.

    If you have Adobe Illustrator create your svg using this program, then it would be a case to add links manually to each box created in the svg code. SVG is an xml-based language and not a real image, even if this is how a browser will display the it.

    PZ

  • I recently bought a new camera from Sony a7 - ii.  the first time I tried to import raw images taken with it (with a. Suffix ARW) the program says "Preview not available for this file" and then "files are not recognized by the raw format support in Lightr

    I recently bought a new camera from Sony a7 - ii.  the first time I tried to import raw images taken with it (with a. Suffix ARW) the program says "Preview not available for this file" and then "files are not recognized by the raw format support in Lightroom" I have the most updated version, I think as 5.7.  What should I do to get these files imported as raw files?

    Hi Bobsirkus,

    The camera you have is compatible with the latest version of Lightroom, which is Lightroom 6/CC.

    Please see the list of the camera supported by Lightroom: supported by Adobe Camera Raw devices

    You can use the DNG Converter, converts images and then import them into DNG in Lightroom.

    Kind regards

    Tanuj

  • Error in connection for the first time, then it works after that (with the same string)

    I have a problem of connection error strange that a "OracleConnection.ConnectionString is not valid" with my program ASP.net/c#, but when I try the page again once it works after that.
    I create the connection string in the code and then pass it a bit like this:

    * private readonly OracleConnection conn = new OracleConnection (oradb); variable in class *.

    * / / in the Page_Load method *.
    _oradb = "password =" + oraPassword + ";". " User ID =' + oraUserName + '; Data source = mydb; » « ;" *
    _conn. Open(); *


    User/login name are also generated and inserted in the connection string and when you debug checked the connection string and it's exactly the same every time. It is as if the connection is interrupted and the first time, it attempts to restore, it gives the error, but then it opens the connection after that and failed again in the same window.
    Any ideas what this might be caused by? I close the connection to another method, after all I want to be the DB and written on the screen.

    The web server is IIS, is the version of .NET 3.5 and the library referenced Oracle is Oracle.DataAccess.dll. In addition, the DB version is 10.2.0.4. Don't know if everything what is necessary, but I thought I'd throw out there, just in case.

    Edited by: psaleh may 24, 2010 23:37

    When you create here of the OracleConnection object.

    * private readonly OracleConnection conn = new OracleConnection (oradb); variable in class *.

    _oradb might be empty or invalid during the first.

    Instead, try this-

    * private readonly OracleConnection _conn = new OracleConnection(); variable in class *.

    * / / in the Page_Load method *.
    _conn. ConnectionString = "password =" + oraPassword + ";". " User ID =' + oraUserName + '; Data source = mydb; » « ;" *
    _conn. Open(); *

    There is a separate forum for the ODP. NET-
    http://forums.Oracle.com/Forums/Forum.jspa?forumid=146

  • How to get the run time on page

    Hello

    I want to display the clock running and the user that loggin.

    Pls knows me how to get the running time display and the user name which connect you.


    thakns
    Kumar

    Hello

    You can use javascript clock and substitution string APP_USER
    This place at the source of the HTML region

    &APP_USER.
    
    

    Use styles to get look like you entered and span tag

    BR, Jari

  • Get the first and the last day of the month...

    Hi friends,

    I'm trying to get the first and last day of a month and wants to implement that in the following code:

    SELECT COALESCE (Date_A, Date_B, Date_C)
    OF the double

    Here Date A and B are in Format DD MM YYYY (March 14, 2008)
    and Date like MM YYYY (March 2008)

    How can I get the Date_C as of March 1, 2008, OR March 31, 2008 if Date A and B are NULL?

    Thank you!

    Published by: user11095386 on April 23, 2009 10:45

    Hello

    In my previous message, I thought that you were starting with strings like ' 03 12 2009"and you want to display in the form of" 12 March 2009'.» If what you have is just the opposite, then simply reverse strings format in my first message. Add a comma, if you want, in the format string.
    I think that's what you want:

    COALESCE ( TO_CHAR ( TO_DATE ( Date_A, 'fmMonth DD YYYY'), 'MM DD YYYY')
             , TO_CHAR ( TO_DATE ( Date_B, 'fmMonth DD YYYY'), 'MM DD YYYY')
             , TO_CHAR ( TO_DATE ( Date_C, 'fmMonth YYYY'),    'MM DD YYYY')
             )
    

    Notice how, on the 3rd line, TO_DATE is called without DD in the format string:

    TO_DATE ( Date_C, 'fmMonth YYYY')
    

    When you do so, by default the day the 1st of the month, so that's all you need to do to convert the VARCHAR2 'March 2009' at the DATE of March 1, 2009.

    If you would like the last day of the month, not the first, when Date_C is selected, then use LAST_DAY:

    COALESCE ( TO_CHAR ( TO_DATE ( Date_A, 'fmMonth DD YYYY'), 'MM DD YYYY')
             , TO_CHAR ( TO_DATE ( Date_B, 'fmMonth DD YYYY'), 'MM DD YYYY')
             , TO_CHAR ( LAST_DAY ( TO_DATE ( Date_C
                                              , 'fmMonth YYYY'
                                )
                         )
                 , 'MM DD YYYY'
                 )
             )
    
  • I bought a brand new iPhone 5 s to the United Kingdom for use in New Zealand. When I'm in New Zealand and put the card sim inside (put a sim card in the first time), he said that it is not supported and it doesn't let me do anything else - cant even get i

    I bought a brand new iPhone 5 s to the United Kingdom for use in New Zealand. When I'm in New Zealand and put the card sim inside (put a sim card in the first time), he said that it is not supported and it doesn't let me do anything else - cant even get into the phone. Why has this happened?

    The United Kingdom, where did buy you it?

  • Firefox crashes while loading images for the first time after windows starts upward

    every time I log on windows, Open firefox and load an image or a site with content firefox flash stops responding for 2 or 3 seconds and then returns to normal after that and everything is fine... it happens only when I open firefox for the first time after starting windows to the top...
    thing I tried
    Start windows and Open firefox in safe mode (does'nt fix the problem)

    updated 13 solved the problem...!

  • upgrade to windows 10, cannot open itunes, it opened the first time, and imported all my songs, but does not open a second time, get the error that the path is not correct and file not found

    upgrade to windows 10, cannot open itunes, it opened the first time, and imported all my songs, but does not open a second time, get the error that the path is not correct and file not found

    Try to repair the security permissions for iTunes for Windows and the empty/corrupted after upgrade/crash iTunes library.

    TT2

  • How can I get the exact time and date on my FAX LOG

    I have a new HP Officejet 6500 has more on my Dell Inspiron Windows XP computer.  How can I get the exact time and date on my FAX log?

    Hi FrederickFrank7,

    Journal of faxes would just follow the time of your printer. Please set the time and date of your printer.

    I am an employee of HP.
    Please indicate the position that solved your problem as "acceptable Solution".

  • I use a USB device for the first time. My computer windows Xp does not recognize. How can I fix this prob, and where can I get the info to fix it?

    When I insert my USB for the first time, it is said that it has malfunctioned, and windows does not recognize it. Am I missing driver for USB or what? I need step by step instructions on how to fix this prob. I'm an amateur. Thank you.

    I need step by step instructions on how to fix this prob. I'm an amateur. Thank you.

    Step 1.  Identify the make and model of the USB device.
    Step 2: Identify the version of Windows XP you have, including service pack (start > run > winver > OK)

    Although the following steps 1 & 2 you could get extra help, I suspect that the 'USB device' has indeed "defective" and you have to go back to where you got it and request a refund or a replacement.

  • When you get a retailer to re - install Vista are you able to burn a copy of Vista as when he was the first new and turned on for the first time?

    Hello and Merry Christmas to all. Sorry its been a while that I had time to be on the forum, (family illness) Anywho my daughter had dropped her Lenovo and although we went through every conceiveable options to retrieve and detaches from the dreaded "black screen" we couldn't. We had the chance to recover his files before he died forever! That was the good part... I had to resume at Tiger Direct, where they installed a new concert 320 H/D and re-installed Vista. Because she graduated she had two of the residence and turned my basement into a hoarders paradise, lol point being that she has no idea where his original disk is so I contacted Lenovo who assured me that they would send me a copy of Vista (how naïve of me) they me sent recovery disc (two games not less and it took more than a month!) that I discovered after the fact that I could have burned my own through Neo-Smart...

    There is one thing that still bothers me and that's when we first pulled his new Lap Top for the first time and installed Vista I remembered that the very last paragraph said to make your own copy of the o/s before your done... what was not done! Is it still possible to make a copy of its operating system now? If Yes, how would go about this, if I wait for her to do it, it will not! She was lucky that I was able to use a slave to its hard disk of my XP Sata-IDE cable and get its files on the drive before it me locked. It has an external H/D as most of the people who do not know how to change their scores on the top of their Tower and get the full use out of them as desk top users do.

    As aways thanks for the fellow forumer for your time and trouble and any help is appreciated.

    Tiggerer

    Hello and Merry Christmas to all. Sorry its been a while that I had time to be on the forum, (family illness) Anywho my daughter had dropped her Lenovo and although we went through every conceiveable options to retrieve and detaches from the dreaded "black screen" we couldn't. We had the chance to recover his files before he died forever! That was the good part... I had to resume at Tiger Direct, where they installed a new concert 320 H/D and re-installed Vista. Because she graduated she had two of the residence and turned my basement into a hoarders paradise, lol point being that she has no idea where his original disk is so I contacted Lenovo who assured me that they would send me a copy of Vista (how naïve of me) they me sent recovery disc (two games not less and it took more than a month!) that I discovered after the fact that I could have burned my own through Neo-Smart...

    There is one thing that still bothers me and that's when we first pulled his new Lap Top for the first time and installed Vista I remembered that the very last paragraph said to make your own copy of the o/s before your done... what was not done! Is it still possible to make a copy of its operating system now? If Yes, how would go about this, if I wait for her to do it, it will not! She was lucky that I was able to use a slave to its hard disk of my XP Sata-IDE cable and get its files on the drive before it me locked. It has an external H/D as most of the people who do not know how to change their scores on the top of their Tower and get the full use out of them as desk top users do.

    As aways thanks for the fellow forumer for your time and trouble and any help is appreciated.

    Tiggerer

    Hey tiggerer

    NeoSmart is software startup repair not a recovery disk to reinstall vista

    and once you have replaced your hard disk you have lost the ability to do the recovery disk from the recovery partition that may have been defective hard disk

    and it depends on your version of vista as to whether you can now make a backup complete pc using microsoft software

    you need vista business or vista ultimate to backup full pc

    read information from microsoft about it at the link below microsoft

    http://Windows.Microsoft.com/en-us/Windows-Vista/back-up-your-programs-system-settings-and-files

    If you have not these versions vista expect from lenovo recovery disks be delivered or buy a third party program to do a full backup pc

    one of these programs is the true picture in the link below

    http://www.Acronis.com/

    have a happy holiday season

    Walter, the time zone traveller

  • Get the first item in the data model

    I'm trying to get the first item in a data model. I expect the following to work, but it returns-1

    var firstItem = myDataModel.indexOf(0)
    

    Row is a table, and data() must return a specified row element:

    if (myDataModel.size() > 0) {
      var firstItem = myDataModel.data([0])
    }
    

    indexOf search a value and returns it is row.

    UPD:

    In ArrayDataModel, there is also. value() function which takes a simple index.

    Data() is more generic function inherited from DataModel.

    So, it can be simplified to:

    var firstItem = myDataModel.value(0)
    
  • I get an error in XP mode everything works for the first time.

    When you start XP mode (on win 7 ultimate) for the first time. "It makes it to the end of the installation, and then said' didn't install correctly, try again" ive linked result withsame several times.  What can I do to get XP running mode?

    Original title: XP mode (in win7 ultimate) installed, but mistakes so that "fisrt time put in place.

    Hi VeryMetal8,

    I would have you post your query in the TechNet forums because it caters to an audience of it professionals.

    Your request would be more out there.

    Check out the link-

    http://social.technet.Microsoft.com/forums/en-us/w7itprovirt/threads

    Recover if you have questions about Windows in the future. We will be happy to help you.

    Thank you.

Maybe you are looking for

  • The latest 33.0 firefox does not display plugin tamper data. I need the plug-in for research purposes

    I had to use data tamper plugin for my current assignment on software security. The plug-in has been successfully installed, but it is not displayed. I do everything wrong or if not is there a problem with the new firefox?

  • I have a problem when I install windows xp

    I need to install windows xp on my laptop When I tried to install windows cp on my laptop, I got the problem below http://i333.Photobucket.com/albums/m375/RCP-Pro/RCPddd.gif Windows could not find my hard drive is my laptop: compaq presario cq57-401s

  • hardware upgrade to the 15-g010nr

    I bought a HP 15-g010nr a few weeks ago and I was wondering What other processors I can update and the amount of RAM is support? The CPU is currently AMD E2-series E2-6110 is tehre any better for this laptop processor?

  • How can I synchronize photos with dropbox

    The idea is to use dropbox as a HD to avoid wasting space from mac hd.

  • My power button is normal?

    I just upgraded to the Razr Maxx from old droid device and power button on my old unit was pretty solid. However, the power button on my Maxx has a few odd wiggle abilities. (It oscillates up and down). I'm just afraid that he could jump off when I g