How do i covert an image in J2ME into an byte array ?

Can anyone help to show me the way to convert an image into a byte array ?
Thanks early reply appreciated.

Hi! I�m developing an application to be installed in two devices. My problem is that i want to send an image: I can receive it with createImage(InputStream ip), but how can i send it with OutputStream? it needs a byte array (method write), how can i convert an image into a byte array?is there any other solution? like send it as a string...
Thanks

Similar Messages

  • How to read an inputStream in UTF-8 into a byte array.

    Hi, Java version is 1.4.2. If inputStream.read() is used to read the bytes into a byte array, is it guarenteed that UTF-8 chars are correctly transferred into byte array? Or should we use InputStreamReader? An example would be a great help.
    Thanks in advance.

    I would like to send a byte array read from InputStream to another app where they are converted to UTF-8. In brief
    -Read input stream which comes in UTF-8 into a byte array
    -Send byte array to another app which will convert it into UTF-8 characters

  • I am using Photoshop CC, how do I scan an image (hand drawn) into photoshop?

    I am using Photoshop CC, how do I scan an image (hand drawn) into photoshop?

    Hello,
    please have a look at "Photoshop Help/Acquiring images from cameras and scanners" >>>
    http://helpx.adobe.com/photoshop/using/acquiring-images-cameras-scanners.html#WSfd1234e1c4 b69f30ea53e41001031ab64-790ca 
    >>> Importing scanned Images and so too here for some critical responses/voices in
    https://forums.adobe.com/thread/1245120
    https://forums.adobe.com/message/6152457
    Hans-Günter

  • How to put a String into a byte array

    How can i put a String into a byte array byte[]. So that i can send it to the serial port for output to an LCD display. Cheers David

    javadocs for String
    getBytes
    public byte[] getBytes()
    Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array.
    Returns:
    The resultant byte arraySince:
    JDK1.1

  • How do I place an image from PS into InDesign?

    Hi,
    I created a notecard in Photoshop and need to put two on a page in InDesign CS3. I placed the graphic on the page but it's way larger than the designated paper size. I tried going to Object>Fitting to fix the problem but nothing happened. So I tried manually setting the height and width I needed the image to be on the page and it resized the image okay but I couldn't see the entire image within the new size. So my question is how do I place an image, get it to the dimensions I need (see dimensions below) and add two to a page?
    FYI: The paper size is: 8.5 x 11 inches. The graphics are 4.25 x 5.5 inches. I need to print two to a page.
    Thanks for the help.
    ashmic

    To add to M Blackburn's advise, the two selection tools will change what you can do.
    The Selection tool (solid black arrow) will allow you to select the frame itself. It will only select the content if you click on the donut. When the frame is selected, you will see the frame with handles on the corners and centers of lines, and it will be in the color designated to the layer. The default color for layer one is blue, but this can be changed, so don't be thrown if it isn't blue for some reason. Dragging the handles will change the size and placement of the frame, and when moved toward the image, will crop it. Holding the shift key while dragging a handle will keep the frame within proportion (a 3"x5" rectangle will remain 3 units by 5 units, although those units will be larger or smaller than an inch, depending on whether you enlarge or shrink the frame).
    The Direct Selection tool (white arrow) will select the content, rather than the frame. When selecting the content, you will see the handles on a bounding box around the content, and the color will be light brown. Dragging a handle will change the size of the image, and you can also drag the whole image to move it in relation to the frame, which can be used to crop the image as well. Holding shift will keep the image size proportional.
    You should take notice of whether the frame color or the content color is what you see, because double-clicking with the Selection tool will toggle between frame and content, the way clicking within the donut will allow content to be edited while the Selection tool is active.
    If you want to view the image size as a percentage, using the Direct Selection tool is what you want. If you use the Selection tool, you will see the percentage of the frame, which will change while you are dragging it, but as soon as you release the mouse button, it will show 100%. Switching to the Direct Selection tool will show you the percentage of reduction or enlargement of the image itself, and if the X and Y aren't the same, your image is out of proportion.
    Lastly, the shift key, along with Command will probably be what you will use the most, as it will allow you to drag a corner of the frame of a placed image with the Selection tool and proportionally resize the content along with the frame.

  • How do I read the images I bundled into the jar file?

    I just wrote an applet that uses
         Toolkit tk = Toolkit.getDefaultToolkit();
         tk.getImage("blah.gif");to load a bunch of image files. The class file and gif images were bundled into a jar file to minimize the number of connections the browser has to make to the server.
    The applet works fine in appletviewer but trips a java.security.AccessControlException: access denied (java.io.FilePermission select.gif read) when run in a browser. I know you normally use Applet.getImage(URL) to load images but wont that circumvent the JAR file and make a seperate connection to the server for each image? That would defeat the purpose of using a JAR file.
    How do I access the image files I bundled into the JAR file?

    From your Applet class, write the following:
    URL imgUrl = getClass().getResource("blah.gif");
    Image img = getImage(imgUrl);The returned URL will be from the Applet class ClassLoader, which will look into the specified archive (jar) file.

  • How can I read the image from database into form

    hi everyone
    if I have table like this
    create table test
    (id number(10),
    pic long raw);
    in this table record
    in form If I have block non database
    how can i read the image into non database item
    I try with this code but no good
    select pic into :photo from test where id=5;
    photo its non database item kind image
    how can i invoke image into item
    thanks alooooooot

    Hello,
    You can't select image with select query. You need to create another database block from test table which has item binds with database pic column. Now in where condition in test block's property you have to write id=5. Change test block's properties UPDATE ALLOWED, INSERT ALLOWED, DELETE ALLOWED to NO. Only Query allowed property set to YES.
    Now in your particular trigger write the code
    GO_BLOCK('test');
    Execute_Query;
    please mark if it help you or correct
    Regards,
    Danish

  • How to add 16 bit message sequential number to the byte array

    hi
    iam trying to implement socket programming over UDP. Iam writing for the server side now.I need to send an image file from server to a client via a gateway so basically ive to do hand-shaking with the gateway first and then ive to send image data in a sequence of small messages with a payload of 1 KB.The data message should also include a header of 16 bit sequential number and a bit to indicate end of file.
    Iam able to complete registration process(Iam not sure yet).I dnt know how to include sequential number and a bit to indicate end of file.
    I would like to have your valuable ideas about how to proceed further
    package udp;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class Sender  {
        protected BufferedReader in = null;
        protected FileInputStream image=null;
        protected static boolean end_of_file=true;
    /** pass arguments hostname,port,filename
    * @param args
    * @throws IOException
       public static void main(String[] args) throws IOException{
            DatagramSocket socket = new DatagramSocket(Integer.parseInt(args[1]));
            boolean more_messages = true;
              String str1=null;
                * gateway registration
                try{
                     //send string to emulator
                    String str="%%%GatewayRegistration SENDER test delay 10 drop 0 dupl 0 bandwidth 1000000";
                    byte[] buff=str.getBytes();
                    InetAddress emulator_address = InetAddress.getByName(args[0]);
                    DatagramPacket packet = new DatagramPacket(buff, buff.length,emulator_address,Integer.parseInt(args[0]));
                    socket.send(packet);
                        // figure out response
                    byte[] buf = new byte[1024];
                    DatagramPacket recpack=new DatagramPacket(buf,buf.length);
                    socket.receive(recpack);
                   // socket.setSoTimeout(10000);
                    String str2=str1.valueOf(new String(recpack.getData()));
                    if(socket.equals(null))
                         System.out.println("no acknowledgement from the emulator");
                        socket.close();
                    else if(str2=="%%%GatewayConfirmation")
                    //     String str1=null;
                         System.out.println("rec message"+str2);
                    else
                         System.out.println("not a valid message from emulator");
                         socket.close();
                catch (IOException e) {
                    e.printStackTrace();
                      end_of_file = false;
         /**create a packet with a payload of 1     KB and header of 16 bit sequential number and a bit to indicate end of file
      while(end_of_file!=false)
          String ack="y";
          String seqnum=
           File file = new File(args[2]);                               
                    InputStream is = new FileInputStream(file);                 
            socket.close();
      private byte[] byteArray(InputStream in) throws IOException {
             byte[] readBytes = new byte[1024]; // make a byte array with a length equal to the number of bytes in the stream
          try{
             in.read(readBytes);  // dump all the bytes in the stream into the array
            catch(IOException e)
                 e.printStackTrace();
            return readBytes;
      

    HI Rolf.k.
    Thank you for the small program it was helpfull.
    You got right about that proberly there  will be conflict with some spurios data, I can already detect that when writing the data to a spreadsheet file.
    I writes the data in such a way, that in each line there will be a date, a timestamp, a tab and a timestamp at the end. That means two columns.
    When i set given samplerate up, that controls the rate of the data outflow from the device, (1,56 Hz - 200 Hz),   the data file that i write to , looks unorderet.
     i get more than one timestamp and severel datavalues in every line and so on down the spreadsheet file.
    Now the question is: Could it be that the function that writes the data to the file,  can't handle the speed of the dataflow in such a way that the time stamp cant follow with the data flowspeed. so i'm trying to set the timestamp to be  with fractions of the seconds by adding the unit (<digit>) in the timestamp icon but its not working. Meaby when i take the fractions off a second within the timestamp i can get every timestamp with its right data value. Am i in deeb water or what do You mean!??
    AAttached Pics part of program and a logfile over data written to file
    regards
    Zamzam
    HFZ
    Attachments:
    DataFlowWR.JPG ‏159 KB
    Datalogfile.JPG ‏386 KB

  • How to get password as string back from encrypted password byte array.

    Hi All,
    I am storing encrypted password and enc key in the database.(Code included encryptPassword method for encryption and validatePassword method for validating of password). Problem is that for some reason i need to show user's password to the user as a string as he/she entered. But i am not able to convert the encrypted password from D/B to original String.
    Tell me if any body know how to get the string password back from the encrypted password byte array after seeing my existing encryption code.
    //********* Code
    private Vector encryptPassword(byte[] arrPwd)
    try
    // parameter arrPwd is the password as entered by the user and to be encrypted.
    byte[] encPwd = null;
    byte[] key = null;
    /* Generate a key pair */
    KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA", "SUN");
    SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");
    keyGen.initialize(1024, random);
    KeyPair pair = keyGen.generateKeyPair();
    PrivateKey priv = pair.getPrivate();
    PublicKey pub = pair.getPublic();
    /* Create a Signature object and initialize it with the private key */
    Signature dsa = Signature.getInstance("SHA1withDSA", "SUN");
    dsa.initSign(priv);
    /* Update and sign the data */
    dsa.update(arrPwd, 0, 12);
    /* Now that all the data to be signed has been read in, generate a signature for it */
    encPwd = dsa.sign();
    /* Now realSig has the signed password*/
    key = pub.getEncoded();
    Vector vtrPwd = new Vector(2);
    vtrPwd.add(encPwd);
    vtrPwd.add(key);
    return vtrPwd;
    catch (Exception e)
    private boolean validatePassword(byte[] arrPwd,byte[] encPwd,byte[] key) throws RemoteException
    try
    // arrPwd is the byte array of password entered by user.
    // encPwd is the encrypted password retreived from D/B
    // key is the array of key through which the password was encrypted and stored.
    X509EncodedKeySpec KeySpec = new X509EncodedKeySpec(key);
    KeyFactory keyFactory = KeyFactory.getInstance("DSA", "SUN");
    PublicKey pubKey = keyFactory.generatePublic(KeySpec);
    /* Encrypt the user-entered password using the key*/
    Signature sig = Signature.getInstance("SHA1withDSA", "SUN");
    sig.initVerify(pubKey);
    /* Update and sign the password*/
    sig.update(arrPwd, 0, 12);
    return sig.verify(encPwd);
    catch (Exception e)
    Help upto any extent would be appreciated.
    Thanx
    Moti Singh

    Hi All,
    I am storing encrypted password and enc key in the
    database.(Code included encryptPassword method for
    encryption and validatePassword method for validating
    of password). Problem is that for some reason i need
    to show user's password to the user as a string as
    he/she entered. But i am not able to convert the
    encrypted password from D/B to original String.No, you are not encrypting the password in your code, you are merely signing it.
    Tell me if any body know how to get the string
    password back from the encrypted password byte array
    after seeing my existing encryption code.It is impossible to retrieve the original text out of a signature.
    You should read up on some encryption basics in order to understand the difference between signing and encrypting. Then you can find examples of how to encrypt something here: http://java.sun.com/j2se/1.4/docs/guide/security/jce/JCERefGuide.html.
    Actually there is one class specifically for keeping keys secure, KeyStore http://java.sun.com/j2se/1.4/docs/api/java/security/KeyStore.html
    - Daniel

  • How can install the Fractal Image plug-in into Firefox for Windows 7?

    I have the plug-in necessary to view fractal images built with the now no longer Iterated Systems program "Fractal Imager." These are files with the .fif extension and the plug-in is needed to view them. The plug in I have is fully functional. The problem I am having is that I needed instructions on how to upload this plug-in into Firefox for Windows.

    There has been a change in where Firefox searches for plugins and the plugins folder in the Firefox program folder is no longer scanned for plugins, so Firefox won't find them anymore if they are installed in the plugins folder instead of the "browser\plugins" folder that Firefox now scans.
    You can set the plugins.load_appdir_plugins pref to true on the about:config page to make Firefox scan the "<install>/plugins/" directory for plugins like the WMP plugin (np-mswmp.dll).
    You can alternatively move plugins from "<install directory>\plugins\" to "<install directory>\browser\plugins\" (create this folder when missing) to make Firefox find them again.
    *http://www.ghacks.net/2013/05/15/why-you-may-have-lost-access-to-plugins-or-extensions-in-firefox-21/
    *http://mike.kaply.com/2013/04/24/major-changes-coming-in-firefox-21/
    *https://support.mozilla.org/kb/windows-media-or-other-plugins-stopped-working

  • How should I save Tritone image for import into InDesign?

    Photoshop only gives me 4 file format options, and InDesign CS4 only accepts one, .EPS
    Otherwise I got the error, "This files uses an unsupported color space."
    There are several .EPS options. I chose "Single File with Color Composite". However, I'm concerned because the image looks fine in Photoshop but a little faded when I import it into InDesign and then export it as a PDF.

    See the reply to your existing thread.
    Mylenium

  • How do you prepare still images before importing into FCP?

    I'm working on a WWI documentary, so there are a lot of photos that need to be imported. Also each image needs to have movement set to them. The images are in a few different formats: JPEG, GIF, TIFF and PDF's. Their file sizes range from 28 KB - 102 MB. I thought of importing them into Photoshop, where I can resize and save as a PNG file. Then I thought I could open the images in Motion, put movement on the images and export each image as a quicktime file using compressor. My settings in FCP are as follows: AJA Kona LH: 525 29.97 Apple ProRes 422 (HQ). Frame size is 720x486. Does anyone know which is the best way to prepare images before importing them into FCP? Does anyone have a different workflow that works better?

    Just make sure that they are bigger than 720x486 if you intend to be doing moves on them. an 28KB? As MASTER pics? Way too small...those will look like crud. But if you can make the images larger, about twice as large as your canvas, then you are fine.
    Tutorial.
    Movement on Stills
    Shane

  • How to pass a Word Document into a byte array?

    Hi All
    I have an application wherin i select multiple files and send them over to a webservice method.The files selected are zipped internally and sent across as a single entity.
    I could pass the files and retrieve them using my test tool to check thir successful send and retrieval as long as the files were in "text" format.
    But now i need to figure a way out to pass word docs or any other content types.I tried passing word docs in the mechanism that works fine for "text" files.But when i retrieve the files,and try to open the word documents the MS Word states that "the file is corrupt and cannot be opened". The following is the code.
    public byte[] getContent(IDfSessionManager sessionManager,String repositoryName, String objectIdString) {
       ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
       StringBuffer sb = new StringBuffer("");
        try {
              System.out.println("Repository Name " + repositoryName);
               mySession = sessionManager.getSession(repositoryName);
               // Get the object ID based on the object ID string.
                DfId dfId = new DfId(objectIdString);
                 if (dfId.isObjectId())
         System.out.println("Successfully fetched id " + dfId);
              IDfSysObject sysObj = (IDfSysObject) mySession.getObject(dfId);
              System.out.println("Content Type ++++++ " + sysObj.getContentType());
              ByteArrayInputStream buf = sysObj.getContent();
              int i = 0;
             InputStreamReader readInput = new InputStreamReader(buf, "UTF8");
             BufferedReader br = new BufferedReader(readInput);
             while (br.ready()) {
            sb.append(br.readLine());
             sb.append("\n");
              String captureText = sb.toString();
         try {
         is = new ByteArrayInputStream(captureText.getBytes("UTF-8"));
                         } catch (UnsupportedEncodingException e) {
                                    e.printStackTrace();
         final int BUF_SIZE = 1 << 8; // 1KiB buffer
         byte[] buffer = new byte[BUF_SIZE];
                    int bytesRead = -1;
                     while ((bytesRead = is.read(buffer)) > -1) {
         outputStream.write(buffer, 0, bytesRead);
         is.close();
         System.out.println("This is byte acquisition ###### >>>>>>>>>>>>>>>>>>>");
         binaryData = outputStream.toByteArray();
         File temp1 = File.createTempFile("Test",".docx");
         FileOutputStream fos = new FileOutputStream(temp1);
         fos.write(binaryData);
         fos.close();
              // Handle any exceptions.
              catch (Exception ex) {
              ex.printStackTrace();
              finally {
                   sessionManager.release(mySession);
              return binaryData;
         }I assume that UTF8 must be applicatbe only to deal with .txt files.
    I would really appreciate your guidance to obtain a way to acquire data from word documents so that i could open and read them without errors.
    Thank You
    Regards

    Hi B1J001
    Following your suggestion i curtailed the code as follows:
    public byte[] getContent(IDfSessionManager sessionManager,String repositoryName, String objectIdString) {
       ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
       StringBuffer sb = new StringBuffer("");
        try {
              System.out.println("Repository Name " + repositoryName);
               mySession = sessionManager.getSession(repositoryName);
               // Get the object ID based on the object ID string.
                DfId dfId = new DfId(objectIdString);
                 if (dfId.isObjectId())
         System.out.println("Successfully fetched id " + dfId);
              IDfSysObject sysObj = (IDfSysObject) mySession.getObject(dfId);
              System.out.println("Content Type ++++++ " + sysObj.getContentType());
              ByteArrayInputStream buf = sysObj.getContent();
              *String testbuf = buf.toString();*
              *testbytearray = testbuf.getBytes();*
            File temp1 = File.createTempFile("Test",".docx");
            FileOutputStream fos = new FileOutputStream(temp1);
            fos.write(testbytearray);
            fos.close();
         // Handle any exceptions.
         catch (Exception ex) {
         ex.printStackTrace();
         finally {
         sessionManager.release(mySession);
         return testbytearray;
         }I am using just the ByteArrayInputStream to access the content. Still my attempt to open the document from the temporary file yields "file corrupt message".Am i going the right path?
    Thank You
    Regards

  • How to read a large file(size around 100 kbytes) into a byte array in JAVA

    aa

    But I cannot use array subscript as a long value.what do you mean?
    are you rying the following:
    long aSize = 100000;
    byte[] array = new byte[aSize];
    if this is the case, then don't do it, for your 100k file int is far more than enough.
    but in case you jsut get error while:
    byte b = array[100000];
    then it's probably because you'r array is of size 100000, that means you have bytes from 0 to 99999 in there, and 100000 is one passed the end of the array.... jus in case make your array size to be 1234567 (far more than needed for your file) and see if you still get that exception, if not, then your array was too small. but if it fixes your prob, then don't leave it as it is, try to work out the right size for array and use that....
    i wouldn't recommend using static array size, since that file might some day be bigger than you expected, and then you'd have to recompile your program.
    HTH

  • How to Read a File into a Byte Array??

    I want to make an array of data objects that works as a byffer to write from a file to another file
    do you have any sygestions?

    The way I would do it (if I dont misunderstand your question) is to use FileInputStream to pass in the streaming data source.
    then read the file source to a list object. For example, LikedList.
    then tell the LikedList to transcribe itself to an array of any type, in this case, byte.

Maybe you are looking for

  • Can't open a CS5.1 file in CS6 - "An unknown error has occured"

    Hi guys, I have a CS5.1 AI file I can still open in 5.1 just fine, but when I try open it in CS6, I get : Any ideas!? Im confused. K

  • Odd event when I use the Command+P shortcut.

    I 've been using LR for a loooong time and never run into this.  When I flag a photo (Command P) the frame advances to the next photo.  I don't want this to happen.  I'm sure I've hit something to cause this, but don't know how to reset it back to NO

  • Can I opt out of super-cookies today?  If so, how?

    I've read that V is using "super-cookies" and this raised some concerns and that V's response was to allow customers to opt-out of their use. Has anyone done this or know how to do it?  Step-by-step...

  • My files are there but wont show on desktop

    My files are there if I look into desktop folder through the finder but In the real scenario of Desktop The files does not display on the Desktop although they are there. how do I make them appear on the desktop

  • I can't open & install update for FlashPlayer

    I successfully downloaded the update for Flash Player. I was prompted to choose a way to open it. I chose Adobe Download Assistant. That didn't work. Can I change my choice, and if so what should I choose. JodiGirl