How do I download an image from a server and store it in EncodeImage

How to download an image from a server and store it in EncodeImage?

It allows you to create an EncodedImage object. so that you can upload an image from a server, you can use HttpConnection to send a request to your server. Then, your server can return the image file. Since he will cross the stream, you can read and store it in a "byteArray". so the ByteArray, you can generate an EncodedImage by calling the EncodedImage.createIncodedImage (byteArray). now that you already have a coded picture.

Tags: BlackBerry Developers

Similar Questions

  • Error on image from the server and display streaming

    Hi all

    Im trying to read an Image that origin of the server and displays on a screen

    Here's the code I'm using to broadcast the image.

    It is streaming on my Simulator as well as on some devices.

    But on some devices, it's not streaming and throw an exception.

    public UrlToEncodedImage(String url)
    {
    HttpConnection connection = null;
    InputStream inputStream = null;
    byte[] dataArray = null;
    
    try
    {
    connection = (HttpConnection) Connector.open(url+getConnectionString(), Connector.READ, true);
    inputStream = connection.openInputStream();
    byte[] responseData = new byte[10000];
    int length = 0;
    StringBuffer rawResponse = new StringBuffer();
    while (-1 != (length = inputStream.read(responseData)))
    {
    rawResponse.append(new String(responseData, 0, length));
    }
    int responseCode = connection.getResponseCode();
    if (responseCode != HttpConnection.HTTP_OK)
    {
    throw new IOException("HTTP response code: "+ responseCode);
    } 
    
    final String result = rawResponse.toString();
    dataArray = result.getBytes();
    }
    catch (final Exception ex)
    { }
    
    finally
    {
    try
    {
    inputStream.close();
    inputStream = null;
    connection.close();
    connection = null;
    }
    catch(Exception e){}
    } 
    
    bitmap = EncodedImage.createEncodedImage(dataArray, 0,dataArray.length);
    // this will scale your image acc. to your height and width of bitmapfield
    
    int multH;
    int multW;
    int currHeight = bitmap.getHeight();
    int currWidth = bitmap.getWidth();
    if(currHeight>350&&currWidth>350){
        bitmap=scaleToFactor(bitmap,currWidth,currHeight,Display.getWidth()-20,250);
    }
    
    }
    public EncodedImage getEncodedImage()
    {
    return bitmap;
    }
    public  EncodedImage scaleToFactor(EncodedImage encoded, int curWidth, int curHeight, int newWidth,
            int newHeight)
    {
         int numerator_width = Fixed32.toFP(curWidth);
         int denominator_width = Fixed32.toFP(newWidth);
         int scale_width = Fixed32.div(numerator_width, denominator_width);
    
         int numerator_height = Fixed32.toFP(curHeight);
         int denominator_height = Fixed32.toFP(newHeight);
         int scale_height = Fixed32.div(numerator_height, denominator_height);
    
         return encoded.scaleImage32(scale_width, scale_height);
    }
    private static String getConnectionString()
    {
        String connectionString = null;
        if(DeviceInfo.isSimulator())
        {
                if(UrlToEncodedImage.USE_MDS_IN_SIMULATOR)
                {
                       connectionString = ";deviceside=false";
                }
                else
                {
                       connectionString = ";deviceside=true";
                }
        }
        else if(WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
        {
           connectionString = ";interface=wifi";
        }
    
        else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT)
        {
            String carrierUid = getCarrierBIBSUid();
            if(carrierUid == null)
            {
             connectionString = ";deviceside=true";
            }
            else
            {
               connectionString = ";deviceside=false;connectionUID="+carrierUid + ";ConnectionType=";
            }
        }                
    
       else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
        {
          connectionString = ";deviceside=false";
        }
    
       else if(CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE)
        {}
        else
        { connectionString = ";deviceside=true";} 
    
        return connectionString;
    }
    private static String getCarrierBIBSUid()
    {
        ServiceRecord[] records = ServiceBook.getSB().getRecords();
        int currentRecord;
    
        for(currentRecord = 0; currentRecord < records.length; currentRecord++)         {             if(records[currentRecord].getCid().toLowerCase().equals("ippp"))             {                 if(records[currentRecord].getName().toLowerCase().indexOf("bibs") >= 0)
                {
                    return records[currentRecord].getUid();
                }
            }
        }
    
        return null;
    }
    

    The underlined part of the code is where the uid is sent as public _.

    Please, look in the code and let me know where the error is, or is there a better way to disseminate the image.

    In the hope that you hear.

    Thank you & best regards

    Krishnan

    Hello

    I found the error.

    It's in the URL sent by the server.

    The URL consisted of http://google.com

    But the format required to retrieve the image on several device would be http://www.google.com.

    Thanks for anyone who tried to help him.

    Krishnan.

  • How to re-download the messages from the server

    On my first PC with Windows 7-64 bit, I have my server settings to leave messages on the server for 55 days.

    I need to re-download the old messages in Thunderbird probably because of some problems with Time Warner Road Runner sometimes a blacklist email Netflix (if it is the proper term). Netflix is aware of the problem with TWC bounce their e-mail.

    I know that if I went to another PC with Thunderbird - all messages former and current latter-day 55 must be downloaded to it.

    But how I download again (if possible) to my main computer with Thunderbird? If I'm going to email based on the web at TWC, my old messages of up to 55 days are listed.

    Thank you very much. Your solution worked perfectly.

  • How to send photos by mms from the server?

    Hello

    I am currently working on mms app.what I do is first download the image of the server and then send.

    but there is a string currentLocation (location of the file we want to fix) parameter to MessagePart.

    so I use it directly from server how can I achieve that.

    pls help...

    thankx.

    Hello

    My problem was solved by using

    Bitmap image=imageObj.originalImage[0];
                PNGEncodedImage encodedImage=PNGEncodedImage.encode(image);
                byte[] contents=encodedImage.getData();
    
  • Download the image to a server

    Hai I am developing a 9300 blackberry application that I want to how to download an image from a server on my phone ' application and display it

    Please someone help me

    find the attachment and change the url of the image.

    Current URL also works the file.

  • I downloaded a few images from the CPD and sent links to complete the download.  How can I get downloads?

    Hello

    It is more a question of support Adobe Stock for a user.

    I downloaded a few images from the CPD and sent an email to do the download.  Since the conversion window Adobe was already open, I didn't cancel the Adobe window.  How can I access the images associated with the links?  I can access is no longer as there is no code.  I didn't know that the images already chosen by download would be unavailable.

    Thank you

    Craig.

    Hi Craig

    I can see your account Adobe Stock 95 unused DPC downloads have been migrated and you have 10 images from your Adobe Stock Plan.

    Is - that so many unused downloads, you expected to migrate?

    Thank you

    Bev

  • How can I download Acrobat DC from a Linux machine to a separate Windows 7 machine?

    How can I download Acrobat DC from a Linux machine to a separate Windows 7 machine?

    Only Linux has Internet connection, but when I start to download, I get the dmg image, I need exe. Where can I decide which file to download?

    The installer may be recognizing the Unix environment and download DMG file.

    You can download executable files at the bottom of the direct download link:

    Download Adobe Acrobat products. Standard, Pro | DC, XI, X

  • How to download an image in the folder and view using MySQL?

    Hello

    I want to create a page where a user can upload a picture and then I want to keep the details of the image in MySQL and PHP dynamic text allows you to display the image. Is it still possible? I have so far failed in my quest to find help on google or anywhere else besides.

    Basically what I want to do is create a page where the houses/lodges can save their information: name of the institution, Image of the institution, location, website, price range, etc. I want to allow them to download a picture from their school and the download location to a folder and, as I mentioned earlier, store only the information required to retrieve and display the image in the MySQL DB. Then, when a customer uses the search page, I want to display the results in a way that will allow them to see the image beside the name.

    Please PLEASE please someone help me I will be more than very happy. If someone has a script they let me use or at least a good tutorial or a link to worthy of information please let me know.

    Thanks in advance.

    Cedric

    There are many facts about PHP scripts or tutorials out there (google 'PHP file upload') that help you download the files in a directory on your server, but I ve never pinned scripts/tutorials that are a little "specific Dreamweaver' and you say how to integrate this functionality with insert/update server behaviors recording existing and even save info to files in a database.

    At this point, you can consider using an extension of Dreamweaver as PHP X Upload (by FelixOne) which seems to satisfy all the requirements you mention.

    See you soon,.

    Günter

  • I downloaded an application from my iphone and then deleted. Now when I open AppStore I purchased apps and its still there. How can I remove it from there though even I have no more app?

    I downloaded an application from my iphone and then deleted. Now when I open AppStore I purchased apps and its still there. How can I remove it from there even if I have no more app?

    The applications that you have downloaded will be available for re - download also a practice.

    Apps y cannot be removed, you can hide only.

    Read here: hide and expose the purchases made on the iBooks Store - Apple Support, App Store or iTunes Store

  • How can I download my ebooks from my computer on my ipad

    How can I download my ebooks from my computer on my ipad

    Are these ebooks that you created yourself?  Or that you have purchased on the Apple iBookstore?

  • How can I download raw images in the photos of el capitan?

    How can I download raw images in the photos of el capitan?

    What camera?

    What happens when you try?

    RAW + JPEG you use?

  • I'm trying to download Security Suite from my provider and I get a message that I have to get rid of PC Cleaner. How can I remove it?

    Get rid of PC Cleaner

    I'm trying to download Security Suite from my provider and I get a message that I have to get rid of PC Cleaner. I searched my PC and that you do not find PC Cleaner. If I don't know how I'll remove it. Thanks for your help. The only reference to PC Cleaner is the Microsoft Security on the PC.

    Go to add/remove programs and see if PC Cleaner is in the list. If so, then click to remove.
    Then go into Windows Explorer. Research on Windows/System32 and see fi there is pcsd.dll and delete it.
    Then go to regedit and search for any mention of PC Cleaner, PC Cleaner and remove these entries.

    Change the settings of the REGISTRY can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the REGISTRY settings configuration can be solved. Changes to these settings are at your own risk.

    Then see if you still get an error of PC Cleaner.

    Let us know if that helps.

    Marilyn

  • How can I download the drivers from Manufacter ' ' s Website if I have no internet.»

    original title: How can I download the drivers from Manufacter ' ' s Website so I havew no internet. ". Computer a wipe trying to download Microsoft XP! Now I can't access the internet.

    How can I download driver manufactuer website if I have no internet service?  Computer was wiped out trying to download Miccrosoft XP.  Now I can't access the internet.

    Hello

    In the case of no internet access, I suggest to download the driver on another computer that has internet access and save it. Later, you can use any flash drive or you can also burn it to a CD for transfer files downloaded to your computer and install the driver file.

    In order to bypass without network problem, follow the link below and check if this can help:

    http://support.Microsoft.com/kb/307164

    http://support.Microsoft.com/kb/314095

  • How can I download an album from my library of music on my ipod shuffle?

    How can I download an album from my library of music on my ipod shuffle?

    I found this on my own.  Thanks anyway for your answer.

  • Loading/downloading the images from the camera

    I downloaded the images from the camera to the computer, then accidentally deleted from the memory card.  Move them back to the memory card?

    I downloaded the images from the camera to the computer, then accidentally deleted from the memory card.  Move them back to the memory card?

    =====================================================
    FWIW... this task is easier to do than to explain.

    (1) connect the camera via a USB cable and turn it on... or insert the memory card in
    your Media Player.

    (2) go to... Start / my computer... your camera should be attached to a drive letter.
    The reader should be recognized as one or several removable disks... it can
    have several drive letters.

    Removable disk (e :))
    Removable drive (g)
    Removable disk (h :))

    Left 3) click on drive letters... When you identify the drive letter for the camera or
    Media Player... (it will be one that does not launch a dialog box indicating:)
    Please insert a disc in the drive?) ...

    Follow these steps...

    4) navigate to the folder in which the photos are... Open it and go... Edition/select all... good
    Click the group selected (highlighted), then from the menu choose... Send to /.
    Removable disk?

    Only a limited number of files can be copied to the root directory of the card... if you
    Transfer lots of pictures... they must be in one or more folders.

    If these files have been changed in any way, rename, rotate, changing the brightness...
    No matter what... the camera will recognize them is no longer, but they will always be on the map
    If you want to use as a backup. You can click on the left to see what is on the drive letter
    the map.

    Volunteer - MS - MVP - Digital Media Experience J - Notice_This is not tech support_I'm volunteer - Solutions that work for me may not work for you - * proceed at your own risk *.

Maybe you are looking for

  • Online zero reference to several points of

    I have several x, y points.  I would like to point there chose 2 and set them to zero as a reference line, then calculate the gap of all other points of this reference line.  LabVIEW has a function that can do this.  Thank you.

  • Update windows XP SP 3 no success.

    I installed XP SP3, but after cutting system processes, it appears the dialog box: SP3 update canceled. Why?

  • KB2502898 fails to install

    I can't install the important KB2502898 update suggests to install Microsoft Update . He failed twice already. The corresponding reports of c:\windows\kb2502898.log log file: ... 83.532: build Num ticks for Cabinet: 32 83.532: DynamicStrings section

  • Socket communication

    Hi guys,. I'm developing a simple socket connection (very basic) I tried this: class ss extends UiApplication {}public static String URL = 'socket://xxx.xxx.xxx.xxx:8010; deviceside = true; APN = internet; » ;StreamConnection conn = null;OutputStream

  • BlackBerry OS 10.3.1 10 screen problem

    Screen zoom since update every time phone is locked and unlocked! I stuck in the screen to update the display to the normal screen again! This happens whenever the phone is keylocked which is a big problem