CreateBitmapFromBytes

Hello I'm trying to create a bitmap on the web using CreateBitmapFromBytes inside the Bitmap class.

I create an input stream and use the IOUtilities to convert the inflow into a byte array. After that, I use the byte [] to create the bitmap. For some reason, it of not crashing but also does not work. Any thoughts?

Bitmap bmp= null;

//create a connection to access the image on the web
StreamConnection imgSC = (StreamConnection)Connector.open(imageURL);

//create input stream from the stream connection
InputStream imgIS = imgSC.openInputStream();

//convert the input stream to a byte array
byte[] imageData = IOUtilities.streamToBytes(imgIS);

//create a bitmap from the byte array
bmp = Bitmap.createBitmapFromBytes(imageData, 0 , -1, 1);

//assign the bitmap to the bitmap field
DisplayedBitmap.setBitmap(bmp);

Tried what you said and there is no error, but he did not finish the function. This is the code:

System.out.println("Starting Image Download");
StreamConnection imgSC = (StreamConnection)Connector.open(imageURL);

System.out.println("Connection Established");
InputStream imgIS = imgSC.openInputStream();

System.out.println("Inputstream Open");
byte[] imageData = IOUtilities.streamToBytes(imgIS);    

System.out.println("Byte array written: "+ imageData.length);

It is the output:

Starting Image Download
Connection Established
Starting net_rim_bb_simphonebook
Started net_rim_bb_simphonebook(166)
EF: 20 SIZE: -1
AG,+CPT
AG,-CPT
JVM: bklt @4186: timer
JVM: bklt[1] @4186: idle 11
JVM: bklt @4186: setTimer 11
SHUTTING DOWN SIM SERVER
Exit net_rim_bb_simphonebook(166)

from what I can tell, it cannot open the inputstream. Correct support?

EDIT: I forgot to take into account the deviceside. and wifi. Fixed by adding

Tags: BlackBerry Developers

Similar Questions

  • Add ButtonField on BitmapFiled

    Hi all

    I tried to use this code to add BitmapButtonField on BitmapField but I couldn't use it.

    Ant one can help me?

    package mypackage;
    
    import com.operations.images.ImageManipulator;
    
    import net.rim.device.api.system.Application;
    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.system.Display;
    import net.rim.device.api.system.JPEGEncodedImage;
    import net.rim.device.api.ui.TouchEvent;
    import net.rim.device.api.ui.TouchGesture;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.BitmapField;
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.Dialog;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.component.SeparatorField;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    
    /**
     * A class extending the MainScreen class, which provides default standard
     * behavior for BlackBerry GUI applications.
     */
    public final class MyScreen extends MainScreen {
    
        private static int rotatedAngle = 360;
    
        // byte[] rrr = resizeImage(Bitmap.getBitmapResource("gear.png"),
        // Display.getWidth(), Display.getHeight() / 2);
        // Bitmap originalBmp = Bitmap.createBitmapFromBytes(rrr, 0, rrr.length, 1);
        Bitmap originalBmp = Bitmap.getBitmapResource("[email protected]");
        BitmapField rotatedBitmap = new BitmapField(originalBmp);
    
        private BitmapButtonField buttonField1 = new BitmapButtonField(
                Bitmap.getBitmapResource("images_1.png"));
        private BitmapButtonField buttonField2 = new BitmapButtonField(
                Bitmap.getBitmapResource("images_2.png"));
    
        VerticalFieldManager bmpManager = new VerticalFieldManager(USE_ALL_WIDTH
                | NO_HORIZONTAL_SCROLL | NO_VERTICAL_SCROLL) {
    
            public int getPreferredHeight() {
                return rotatedBitmap.getHeight();
            };
    
            public int getPreferredWidth() {
                return rotatedBitmap.getWidth();
            };
    
            protected void sublayout(int maxWidth, int maxHeight) {
    
                layoutChild(rotatedBitmap, originalBmp.getWidth(),
                        originalBmp.getHeight());
                layoutChild(buttonField1, buttonField1.getPreferredWidth(),
                        buttonField1.getPreferredHeight());
                layoutChild(buttonField2, buttonField2.getPreferredWidth(),
                        buttonField2.getPreferredHeight());
    
                setPositionChild(rotatedBitmap, 0, 0);
                setPositionChild(buttonField1, 0, 50);
                setPositionChild(buttonField2, 50, 50);
    
                super.sublayout(getPreferredWidth(), getPreferredHeight());
                setExtent(getPreferredWidth(), getPreferredHeight());
    
            };
        };
    
        VerticalFieldManager manager = new VerticalFieldManager(USE_ALL_WIDTH
                | NO_HORIZONTAL_SCROLL | NO_VERTICAL_SCROLL) {
    
            public int getPreferredHeight() {
                return Display.getHeight() - bmpManager.getPreferredHeight();
            };
    
            public int getPreferredWidth() {
                return Display.getWidth();
            };
        };
    
        /**
         * Creates a new MyScreen object
         */
        public MyScreen() {
            super(USE_ALL_WIDTH | USE_ALL_HEIGHT);
            // Set the displayed title of the screen
            setTitle("Test Animation");
    
            bmpManager.add(rotatedBitmap);
            bmpManager.add(buttonField1);
            bmpManager.add(buttonField2);
    
            manager.add(new SeparatorField());
            manager.add(new SeparatorField());
            manager.add(new LabelField(" label 1 "));
            manager.add(new LabelField(" label 2 "));
            manager.add(new LabelField(" label 3 "));
    
            add(bmpManager);
    
            add(manager);
    
        }
    
        protected boolean touchEvent(TouchEvent message) {
            switch (message.getEvent()) {
            case TouchEvent.CLICK:
                // invokeDialog("-->CLICK");
                return true;
            case TouchEvent.DOWN:
                // invokeDialog("-->DOWN");
                return true;
    
            case TouchEvent.GESTURE:
                TouchGesture gesture = message.getGesture();
                int gestureCode = gesture.getEvent();
    
                if (gesture.getSwipeDirection() == TouchGesture.SWIPE_NORTH) {
                    invokeDialog("swip north : " + gesture.getSwipeAngle() + " , "
                            + gesture.getSwipeMagnitude());
                } else if (gesture.getSwipeDirection() == TouchGesture.SWIPE_SOUTH) {
                    invokeDialog("swip south : " + gesture.getSwipeAngle() + " , "
                            + gesture.getSwipeMagnitude());
                } else if (gesture.getSwipeDirection() == TouchGesture.SWIPE_EAST) {
                    if ((message.getX(1) >= bmpManager.getContentRect().x && message
                            .getX(1) <= bmpManager.getContentRect().width)
                            && (message.getY(1) >= bmpManager.getContentRect().y && message
                                    .getY(1) <= bmpManager.getContentRect().height)) {
    
                        // invokeDialog("swip east : " + gesture.getSwipeAngle()
                        // + " , " + gesture.getSwipeMagnitude());
                        rotate(true);
    
                    }
                } else if (gesture.getSwipeDirection() == TouchGesture.SWIPE_WEST) {
                    if ((message.getX(1) >= bmpManager.getContentRect().x && message
                            .getX(1) <= bmpManager.getContentRect().width)
                            && (message.getY(1) >= bmpManager.getContentRect().y && message
                                    .getY(1) <= bmpManager.getContentRect().height)) {
    
                        // invokeDialog("x = " + bmpManager.getContentRect().x +
                        // " , "
                        // + bmpManager.getContentRect().width + " \ny = "
                        // + bmpManager.getContentRect().y + " , "
                        // + bmpManager.getContentRect().height + "\n mx = "
                        // + message.getX(1) + " , " + message.getY(1));
                        // invokeDialog("swip west : " + gesture.getSwipeAngle()
                        // + " , " + gesture.getSwipeMagnitude());
                        rotate(false);
    
                    }
                }
    
                return true;
    
            case TouchEvent.MOVE:
                // int moveSize = message.getMovePointsSize();
                // int[] x_points;
                // int[] y_points;
                // int[] time_points;
                // int size = message.getMovePointsSize();
                // x_points = new int[size];
                // y_points = new int[size];
                // time_points = new int[size];
                // message.getMovePoints(1, x_points, y_points, time_points);
                //
                // if (x_points.length >= 50) {
                // invokeDialog("-->move : " + size);
                // }else if(x_points.length == 2){
                // invokeDialog("-->move : ssss = " + 2);
                // }
                return true;
            }
            System.out.println("PRINT ME SOMETHING IN ANY CASE");
            return false;
        }
    
        private void rotate(final boolean east) {
    
            synchronized (Application.getEventLock()) {
                UiApplication.getUiApplication().invokeLater(new Runnable() {
    
                    public void run() {
                        // wipe east
                        if (east) {
                            // if (rotatedAngle >= 0) {
                            for (int i = 0; i < 45; i += 1) {
                                try {
                                    rotatedAngle -= i;
                                    rotatedBitmap.setBitmap(ImageManipulator
                                            .rotate(originalBmp, rotatedAngle));
                                    bmpManager.invalidate();
                                    // bmpManager.deleteAll();
                                    // bmpManager.add(new
                                    // BitmapField(rotatedBitmap));
    
                                    // Thread.sleep(100);
                                } catch (Exception e) {
                                }
                            }
                            // }
                        } else {
                            // swipe weast
                            // if (rotatedAngle <= 360) {
                            for (int i = 0; i < 45; i += 1) {
                                try {
                                    rotatedAngle += i;
                                    rotatedBitmap.setBitmap(ImageManipulator
                                            .rotate(originalBmp, rotatedAngle));
                                    bmpManager.invalidate();
                                    // bmpManager.deleteAll();
                                    // bmpManager.add(new
                                    // BitmapField(rotatedBitmap));
    
                                    // Thread.sleep(100);
                                } catch (Exception e) {
                                }
                            }
                            // }
    
                        }
                    }
                });
    
            }
        }
    
        public static void invokeDialog(final String msg) {
            UiApplication.getUiApplication().invokeLater(new Runnable() {
    
                public void run() {
                    Dialog.inform(msg);
                }
            });
        }
    
        public static byte[] resizeImage(Bitmap srcBitmap, int width, int height) {
            // int width = 0;
            // int height = 0;
            // Bitmap srcBitmap = Bitmap.createBitmapFromBytes(image, 0,
            // image.length,
            // 1);
            // if (srcBitmap.getWidth() > srcBitmap.getHeight()) {
            // width = widthT;
            // height = (widthT * srcBitmap.getHeight()) / srcBitmap.getWidth();
            // } else if (srcBitmap.getWidth() < srcBitmap.getHeight()) {
            // height = heightT;
            // width = (height * srcBitmap.getWidth()) / srcBitmap.getHeight();
            // } else {
            // width = widthT;
            // height = heightT;
            // }
            Bitmap destBitmap = new Bitmap(width, height);
            srcBitmap.scaleInto(destBitmap, Bitmap.FILTER_BILINEAR);
            JPEGEncodedImage encoded = JPEGEncodedImage.encode(destBitmap, 100);
            return encoded.getData();
        }
    }
    

    Thank you

    I tried to improve my code and I found the solution

    /**
     * @author : Ahmed Shoeib
     * @description : add BitmapButtonField over BitmapField
     */
    public final class MyScreen extends MainScreen {
    
        Bitmap originalBmp = Bitmap.getBitmapResource("[email protected]");
        BitmapField rotatedBitmap = new BitmapField(originalBmp);
    
        BitmapButtonField buttonField1 = new BitmapButtonField(
                Bitmap.getBitmapResource("images_1.png"));
        BitmapButtonField buttonField2 = new BitmapButtonField(
                Bitmap.getBitmapResource("images_2.png"));
    
        Manager mainManager = new Manager(USE_ALL_WIDTH | NO_HORIZONTAL_SCROLL
                | NO_VERTICAL_SCROLL) {
    
            public int getPreferredHeight() {
                return rotatedBitmap.getHeight();
            };
    
            public int getPreferredWidth() {
                return rotatedBitmap.getWidth();
            };
    
            protected void sublayout(int width, int height) {
    
                setPositionChild(rotatedBitmap, 0, 0);
                layoutChild(rotatedBitmap, rotatedBitmap.getPreferredWidth(),
                        rotatedBitmap.getPreferredHeight());
    
                setPositionChild(buttonField1, getPreferredWidth() / 2, 0);
                layoutChild(buttonField1, buttonField1.getPreferredWidth(),
                        buttonField1.getPreferredHeight());
    
                setPositionChild(buttonField2, getPreferredWidth() / 2,
                        getPreferredHeight() / 2);
                layoutChild(buttonField2, buttonField2.getPreferredWidth(),
                        buttonField2.getPreferredHeight());
    
                setExtent(getPreferredWidth(), getPreferredHeight());
            }
        };
    
        VerticalFieldManager bottomManager = new VerticalFieldManager(USE_ALL_WIDTH
                | NO_HORIZONTAL_SCROLL | NO_VERTICAL_SCROLL) {
    
            public int getPreferredHeight() {
                return Display.getHeight() - mainManager.getPreferredHeight();
            };
    
            public int getPreferredWidth() {
                return Display.getWidth();
            };
        };
    
        /**
         * Creates a new MyScreen object
         */
        public MyScreen() {
            super(USE_ALL_WIDTH | USE_ALL_HEIGHT);
            // Set the displayed title of the screen
            setTitle("Test Animation");
    
            mainManager.add(rotatedBitmap);
            mainManager.add(buttonField1);
            mainManager.add(buttonField2);
    
            bottomManager.add(new LabelField("fffffffffff"));
            bottomManager.add(new LabelField("fffffffffff"));
            bottomManager.add(new LabelField("fffffffffff"));
    
            add(mainManager);
            add(bottomManager);
    
        }
    
    }
    

    Thank you

  • Impossible to read data from SD card

    Hello

    I'm reading of bmp on SD card files

    String mybmp = file:///fs-sdcard-root/BlackBerry/BMPImages/myimage.bmp
    IMG = Bitmap.getBitmapResource (mybmp);

    I get img as NULL.

    The similator parameter includes:

    FS - sdcard = true/fs-sdcard-root = "C:\SimSDCard".

    The location of the file in my system is: C:\SimSDCard\BlackBerry\BMPImages\myimage.bmp

    Please tell me what I'm missing.

    Thank you!

    Copy the following code:

    String mybmp = "file:///SDCard/BlackBerry/pictures/mybmp.bmp";
    InputStream is = getClass().getResourceAsStream(mybmp);
    

    cannot possibly succeed. getResourceAsStream search a resource provided with your application in the .cod file, not on the SD card.

    With the second code, it would be useful to know where it is a failure. But before that, you can verify that the image file is in fact on the (simulated) SD card. That, at the opening of the media, and then selecting "Explorer" in the menu. You should see two roots: 'Media Card' and 'memory of the device. If you have not then you have a problem of configuration of the Simulator as Jerome Carty suggested. If 'Media Card' is present, you should be able to verify that your image file is present. Still, if it isn't, you have a problem with configuration of the Simulator.

    Assuming that the Simulator is set correctly as described above, try this version of your code, which provides more error checking and diagnostics information:

    String url = "file:///SDCard/BlackBerry/pictures/looxcie98.bmp";
    FileConnection fconn = null;InputStream is = null;try {
       fconn = (FileConnection)  Connector.open(url, Connector.READ);
       if (!fconn.exists()) {
          throw new IOException("No such file!");
       }
       is = fconn.openInputStream();
       NoCopyByteArrayOutputStream bos = new NoCopyByteArrayOutputStream();
       byte[] buffer = new byte[1024];
       int len;
       while ((len = is.read(buffer)) > 0) {
          bos.append(buffer, 0, len);
       }
       img = Bitmap.createBitmapFromBytes(bos.getByteArray(), 0, bos.size(), 1);
    } catch (IOException e) {
       System.out.println(e.toString());
    } finally {   if (is != null) {      try { is.close(); } catch (IOException ignored) {}   }   if (fconn != null) {      try { fconn.close(); } catch (IOException ignored) {}   }}
    
  • Picture taken with the camera...

    Hi all

    I am currently facing a lot of problems to use the camera. After days and days of trying to change/adapt my code, you are my last hope...

    What I want to do is:

    1. Departure from camera
    2. The take a snapshot
    3. Resizing in my application
    4. Store in the FET (don't cause me problems)

    Here is part of my code:

    1. Beginning camera & look the file system
        public CameraBlackBerry() {
    //            invoking camera
            UiApplication.getApplication().addFileSystemJournalListener(this);
            Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA, new CameraArguments());
        }
    

    2 get path to the new image and transfer to another class

        public void fileJournalChanged() {
            AIDOO.debug(">>>>>>>> FS MODIFIED !!!");
            Application app = UiApplication.getApplication();
            app.removeFileSystemJournalListener(this);
            long USN = FileSystemJournal.getNextUSN();
            for (long i = USN - 1; i >= 0; i--) {
                System.out.println(">>>>>>>> FS MODIFIED !!! : " + i);
                FileSystemJournalEntry entry = FileSystemJournal.getEntry(i);
                if (entry.getEvent() == FileSystemJournalEntry.FILE_ADDED) {
                    path = entry.getPath();
                    if (path.endsWith(".jpg")) {// Try to kill camera app here by injecting esc. HAD to remove condition '&& path.indexOf("IMG") >= 0' because changed in OS6
                        //#ifdef DebugMode
                        AIDOO.debug(">>>>>>>> Found a file added ending with jpg @  :" + path);
                        //#endif
                        // Get out of camera app
                        EventInjector.KeyEvent inject = new EventInjector.KeyEvent(EventInjector.KeyEvent.KEY_DOWN, Characters.ESCAPE, 0);
                        inject.post();
                        inject.post();
                        app.requestForeground();
                        AIDOO.currentCameraBlackBerry = null;
                        new CameraBlackBerryFileHandler(path);
                        break;
                    }
                }
                if (entry == null) {
                    // we didn't find an entry.
                    break;
                }
            }
        }
    

    3. how to get a FileConnection

        private FileConnection openFile() {
            try {
                FileConnection file = (FileConnection) Connector.open("file://" + path);
                if (file != null) {
                    boolean fileExists = file.exists();
                    int existCount = 0;
                    while (!fileExists && existCount < 50) {
                        AIDOO.debug("fileExists sleeping for 100 msecond");
                        Thread.sleep(100);
                        fileExists = file.exists();
                        existCount++;
                    }
                    if (existCount < 50 && fileExists) {
                        return file;
                    } else {
                        return null;
                    }
                } else {
                    return null;
                }
            } catch (InterruptedException ex) {
                alerta = new Alert(Lng.getString(Lng.a_alert), "InterruptedException while opening picture connection : " + ex.getMessage() + "  " + ex.getClass() + " path :" + path, null, null);
                AIDOO.handleError("Exception while opening picture connection", ex);
                return null;
            } catch (IllegalArgumentException ex) {
                alerta = new Alert(Lng.getString(Lng.a_alert), "IllegalArgumentException while opening picture connection : " + ex.getMessage() + "  " + ex.getClass() + " path :" + path, null, null);
                AIDOO.handleError("Exception while opening picture connection", ex);
                return null;
            } catch (ConnectionNotFoundException ex) {
                alerta = new Alert(Lng.getString(Lng.a_alert), "ConnectionNotFoundException while opening picture connection : " + ex.getMessage() + "  " + ex.getClass() + " path :" + path, null, null);
                AIDOO.handleError("Exception while opening picture connection", ex);
                return null;
            } catch (IOException ex) {
                alerta = new Alert(Lng.getString(Lng.a_alert), "IOException while opening picture connection : " + ex.getMessage() + "  " + ex.getClass() + " path :" + path, null, null);
                AIDOO.handleError("Exception while opening picture connection", ex);
                return null;
            }
        }
    

    4 getting the stream

        private DataInputStream tryAccessingImage(FileConnection file) {
            DataInputStream is = null;
            nbBytes = 0;
            try {
                is = file.openDataInputStream();
            } catch (IOException ex) {
                return null;
            }
            if (is != null && file.canRead()) {
                try {
                    nbBytes = file.fileSize();
                    isAvailNbBytes = is.available();
                    int unreadableCount = 0;
                    while (nbBytes <= 0 && unreadableCount < 50) {
                        AIDOO.debug("fileSize problem, sleeping for 100 msecond");
                        Thread.sleep(100);
                        nbBytes = file.fileSize();
                        unreadableCount++;
                    }
                    if (unreadableCount < 50) {
                        return is;
                    } else {
                        return null;
                    }
                } catch (InterruptedException ex) {
                    String problem = Lng.getString(Lng.pic_couldnt_be_stored) + "(2) " + ex.getMessage() + "/ InterruptedException can read file : " + file.canRead() + " " + nbBytes + "bytes / " + path;
                    append(problem, imageProblem);
                    alerta = new Alert(Lng.getString(Lng.a_alert), problem, null, null);
                    return null;
                } catch (IOException ex) {
                    String problem = Lng.getString(Lng.pic_couldnt_be_stored) + "(2) " + ex.getMessage() + "/ IOException2 can read file : " + file.canRead() + " " + nbBytes + "bytes / " + path;
                    append(problem, imageProblem);
                    alerta = new Alert(Lng.getString(Lng.a_alert), problem, null, null);
                    return null;
                }
            } else {
                alerta = new Alert(Lng.getString(Lng.a_alert), Lng.getString(Lng.pic_couldnt_be_stored) + "(2) / InterruptedException can read file : " + file.canRead() + " " + nbBytes + "bytes / " + path, null, null);
                return null;
            }
        }
    

    5 reading the stream

        private byte[] readingImage(DataInputStream is) {
            byte[] raw = new byte[(int) nbBytes];
            isReadBytes = -2; // -2 to differ from eventual -1, 0 or n (positive) returned by read()
            try {
                isReadBytes = is.read(raw);
                return raw;
            } catch (IOException ex) {
                String problem = Lng.getString(Lng.pic_couldnt_be_stored) + "readingImage " + ex.getMessage() + "/ IOException1 can read file : " + nbBytes + "bytes / " + path;
                append(problem, imageProblem);
                alerta = new Alert(Lng.getString(Lng.a_alert), problem, null, null);
                return null;
            }
        }
    

    6 then I do the following

    try {
                            is.close();
                            screenWidth /= 4;
                            screenWidth *= 3;
                            screenHeight /= 4;
                            screenHeight *= 3;
                            append("resizing image", imageBlank16);
                            raw = resizeImage(raw, 640, 480);
                            append("resize for preview image", imageBlank16);
                            byte rawPreview[] = resizeImage(raw, screenWidth, screenHeight);
                            AIDOO.debug("ok here");
                            append("creating preview image", imageBlank16);
                            imagePreview = Image.createImage(rawPreview, 0, rawPreview.length);
                            AIDOO.debug("ok here2");
                            String devinceInfo = DeviceInfo.getSoftwareVersion();
                            AIDOO.debug(devinceInfo);
                            AIDOO.debug("ok here3");
                            //#if !BlackBerry_OS_46 && !BlackBerry_Older_than_46
                            //raw = resizeImage(raw);
                            nbBytes = raw.length;
                            //#endif
                            if (nbBytes > CAMERA_IMAGE_MAX_SIZE) {
                                alerta = new Alert(Lng.getString(Lng.a_alert), Lng.getString(Lng.pic_size_is_too_large) + " : " + nbBytes, null, null);
                                System.out.println("error 2 after insert");
                                returnValue = false;
                            }
                        } catch (IOException ioe) {
                            alerta = new Alert(Lng.getString(Lng.a_alert), "IOException : " + ioe.getMessage() + "available Bytes : " + nbBytes, null, null);
                            AIDOO.handleError("IO problem while saving picture 0", ioe);
                            System.out.println("error 2 after insert");
                            returnValue = false;
                        }
    

    7 Behold my image resizing function

        private byte[] resizeImage(byte[] image, int width, int height) {
            AIDOO.debug("Start of image resizing");
            Bitmap bmp1 = null, bmp2 = null;
            try {
                bmp1 = Bitmap.createBitmapFromBytes(image, 0, -1, 1);
                bmp2 = new Bitmap(width, height);
            } catch (IllegalArgumentException ex) {
                throw new IllegalArgumentException("exception while createBitmapFromBytes()" + ex.getMessage() + "isAvailNbBytes = " + isAvailNbBytes + " isReadBytes = " + isReadBytes + " length = " + image.length + " nbBytes = " + nbBytes + " image = " + image);
            }
            AIDOO.debug("Scale into");
            bmp1.scaleInto(bmp2, Bitmap.FILTER_BILINEAR, Bitmap.SCALE_TO_FIT);
            AIDOO.debug("End of Scale into");
            JPEGEncodedImage encoded = JPEGEncodedImage.encode(bmp2, 90);
            return encoded.getData();
        }
    

    My problems are:

    1. sometimes the image is cropped, this size (w/h) is OK, but for some strange reason it is not all the time. There is always a large black area at the bottom of the image. It seems that something has not been correctly readen.

    2. sometimes I had an IllegalArgumentException in createBitmapFromBytes() function.

    I read a lot of posts that talk about these problems, but I have found no solution.

    Is it so hard to take a picture of the camera and display it?

    Anyone have a good example/code example on how to handle this?

    Thank you for your support and for reading me

    (Sorry for my English )

    I suspect that these problems are caused by the fact that the earpiece of the paper you use is told on the file being written until the writing is actually completed.

    I think that Ihad this problem in an application that I wrote and to get around it, rather than process the image in the JournalListener, I actually got the JournalListener to save the file created in the method of invocation of the "onExposed" screen, I checked to see if the name of the file has been updated and if so , I would treat it then.  onExposed is not get leads until the camera application has closed at this time, according to me, that it is save saying that the file has been saved.

    I think that there are other options.  For example, you could start a thread check the size of the file and if it does not grow after a second or two, you might assume that the writing was completed.

    In all cases, this is where I would start looking for the problem.

  • compression of image and convert between Bitmap and byte]

    Hello

    I'm trying to compress an image raw data(byte[]), and here's what I did:

    Bitmap image = Bitmap.createBitmapFromBytes( _raw, 0, -1, 7 );
    Bitmap scaledBitmap = new Bitmap(192, 144);
    image.scaleInto(scaledBitmap, Bitmap.FILTER_BILINEAR, Bitmap.SCALE_TO_FIT);
    

    So now that I have a compressed Bitmap, scaledBitmap and I want the gross data(byte[]) extract from the scaledBitmap. I noticed there is a getRGB565 method, but I don't know how to use it. Can someone give me an example on how to extract the raw data? If it is not possible, is there another way to compress the _raw?

    Thanks in advanc

    I found the solution:

    Bitmap image = Bitmap.createBitmapFromBytes( _raw, 0, -1, 8 );
    
    int newWidth = 192;
    int newHeight = 144;
    
    Bitmap scaledBitmap = new Bitmap(newWidth, newHeight);
    image.scaleInto(scaledBitmap, Bitmap.FILTER_BILINEAR, Bitmap.SCALE_TO_FIT);
    PNGEncodedImage encoder = PNGEncodedImage.encode(scaledBitmap);
    byte[] resizedBytes = encoder.getData();
    
  • camera / snapshot...

    I scoured the forums, found several "solutions" to this problem, but not a single 'solution' of the works of threaded discussion. Because I'm new, I have the newest of the current SDK to run on Eclipse, the steps that I'm trying to figure is as follows:

    (1) display of the user interface, initialize the object camera full screen (not in a domain)

    (2) that the user can take a picture, then immediately close the camera after taking the photo

    (3) add a thumbnail preview to the current form of screen UI (FIELD), which is simple and shows the photo

    (4) save the captured image in the memory of the device in a folder that I created or on the SD card in a folder that I created

    (5) get the name of this file when it has been recorded in the folder, the file name must be unique similar GUID and returned at the time where the file was saved

    I worked on this for the past few days, the code I still does not work as follows:

    private void initCamera()
    {
      try
       {
         //Create a player for the Blackberry's camera.
         Player player = javax.microedition.media.Manager.createPlayer( "capture://video" );
    
         //Set the player to the REALIZED state (see Player docs.)
         player.realize();
    
         //Grab the video control and set it to the current display.
         vc = (VideoControl)player.getControl( "VideoControl" );
    
         if (vc != null)
         {
              //Create the video field as a GUI primitive (as opposed to a
              //direct video, which can only be used on platforms with
              //LCDUI support.)
              _videofeed = (Field) vc.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
              //Display the video control
              vc.setVisible(true);
          }
    
          //Set the player to the STARTED state (see Player docs.)
          player.start();
      }
      catch(Exception e)
      {
          log( "ERROR " + e.getClass() + ":  " + e.getMessage() );
      }
    }
    
    private void setupSnapshot()
    {
      encoding = "encoding=jpeg&width=640&height=480&quality=normal";
    
      snapshotButton = new ButtonField("Capture", ButtonField.CONSUME_CLICK | ButtonField.NEVER_DIRTY | ButtonField.HCENTER);
      listenerSnapshot = new FieldChangeListener() {
        public void fieldChanged(Field field, int context) {
             log(encoding);
                 snapShot();
        }
      };
      snapshotButton.setChangeListener(listenerSnapshot);
      add(snapshotButton);
    }
    
    private void cleanSnapshot()
    {
      Manager m;
      try
      {
        if(snapshotButton != null)
        {
          m=snapshotButton.getManager();
          if(m != null)
            m.delete(snapshotButton);
        }
      }
      catch(Exception ex)
      {
        log("Error: " + ex.toString());
      }
    }
    

    When you capture instant, it will not create an image file and save it to memory. It returns an array of raw image data and you will need to create image from data line and save it in the file system. You already create image of row data.

    byte[] imageBytes = vc.getSnapshot(encoding);
          Bitmap image = Bitmap.createBitmapFromBytes(imageBytes, 0, imageBytes.length, 5);
    

    Now you need to save this image using the FileConnection API to the memory of the device or SD card. Here you must assign the unique image name which may be the current date & time.

    public static String dateFormat()
    {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        return sdf.format(Calendar.getInstance().getTime());
    }
    

    Here is Snap from sample RIM, which saves the image.

    /**
        * A listener used for the "Save" button
        */
        private class SaveListener implements FieldChangeListener
        {
            /** A byte array representing an image */
            private byte[] _raw;
    
           /**
            * Constructor.
            * @param raw A byte array representing an image
            */
            SaveListener(byte[] raw)
            {
                _raw = raw;
            }
    
           /**
            * Saves the image as a file in the BlackBerry filesystem
            */
            public void fieldChanged(Field field, int context)
            {
                try
                {
                    // Create the connection to a file that may or
                    // may not exist.
                    FileConnection file = (FileConnection)Connector.open( FILE_NAME + _counter + EXTENSION );
    
                    // If the file exists, increment the counter until we find
                    // one that hasn't been created yet.
                    while( file.exists() )
                    {
                        file.close();
                        ++_counter;
                        file = (FileConnection)Connector.open( FILE_NAME + _counter + EXTENSION );
                    }
    
                    // We know the file doesn't exist yet, so create it
                    file.create();
    
                    // Write the image to the file
                    OutputStream out = file.openOutputStream();
                    out.write(_raw);
    
                    // Close the connections
                    out.close();
                    file.close();
                }
                catch(Exception e)
                {
                    CameraDemo.errorDialog("ERROR " + e.getClass() + ":  " + e.getMessage());
                }
    
                // Inform the user where the file has been saved
                Dialog.inform( "Saved to " + FILE_NAME + _counter + EXTENSION );
    
                // Increment the image counter
                ++_counter;
    
                // Return to the main camera screen
                UiApplication.getUiApplication().popScreen( _imageScreen );
            }
        }
    

    in your case, you can replace

    FILE_NAME + _counter + EXTENSION
    

    with

    String fileName = dateFormat + EXTENSION;
    

    that will give the unique name of the image.

    I hope this will solve your problem, if not you can always come here

  • Problem with image extract the content and the tile at the same time show on ListField

    My application is Application News get JSON webservice to appear on ListField.

    On each line in the list, it will show you the image thumbnail, title and Teaser as below.

    _______________________________________

    |                |                       Title

    |   Thumb  |_______________________________

    |_______  |                       Teaser

    First of all, I have to get JSON that contains the url of the thumbnail image, title and Teaser.


    I managed to view the title and Teaser, but the thumbnail is not. When I Fetch image with the url of the thumbnail image, it returns only bitmap = null for me.

    My method is first call httpdispatcher to get the thumbnail image, title and Teaser and then wait and call another httpdispatcher to retrieve the url of the image thumbnail, then added to listfield.

    Here is my code

    Class helloScreen{
    
    public void requestSucceeded(byte[] result, String contentType)   {      if (contentType.equals("image/png") ||        contentType.equals("image/jpeg") || contentType.equals("image/gif") ||contentType.equals("image/jpg")) {         bitmap_temp = Bitmap.createBitmapFromBytes(result, 0, result.length, 1);                     synchronized (UiApplication.getEventLock()) {
    
                   }         }         else if (contentType.startsWith("text/")) {
    
                  strResult = new String(result);
    
                 try {                     ja = new JSONArray(strResult);
    
                  } catch (JSONException e) {                   // TODO Auto-generated catch block                    e.printStackTrace();              }
    
               synchronized (UiApplication.getEventLock()) {
                                  int temp_int_next=0;
                    try {
                        callback.erase();
                         for(int x=0;x<10;x++){
    
                             j = (JSONObject) ja.get(x);
    
     String get_htmlOff_first = j.get("teaser").toString().substring(j.get("teaser").toString().indexOf(">")+1);
     final String thumb = replace(j.get("thumb").toString(),"files/","http://www.eng.chula.ac.th/files/");
    
                                    UiApplication.getUiApplication().invokeAndWait(new Runnable() {
    
                                    public void run() {
    
                           getImageURL(thumb); 
    
                                 }});                      
    
    callback.insert(j.get("title")+" ", ""+get_htmlOff_first.trim(), bitmap_temp , temp_int_next , "Event");                      temp_int_next++;
    
                      }
    
                       } catch (JSONException e) {                  // TODO Auto-generated catch block                    e.printStackTrace();              }               
    
                }         }         else {            synchronized (UiApplication.getEventLock()) {         Dialog.alert("Unknown content type: " + contentType);         }         }
    
    
    
    public void getImageURL(String url) {                HttpRequestDispatcher dispatcher2 = new HttpRequestDispatcher(url,                "GET", this);    }
    

    }

    httpRequest, class Dispatcher is used to get the data from the url

    public HttpRequestDispatcher(String url, String method, helloScreen screen)
    {
    this.url = url;
    this.method = method;
    this.screen = screen;
    
    }
    
    public String getType(){
    
        return type;
    
    }
    
    public void run() {
        try {
    
            if(WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
           {
                connection = (HttpConnection)Connector.open(url+";interface=wifi");
         }else{
    
            String uid = getWap2Uid();
            connection = (HttpConnection)Connector.open(url+";deviceside=true;ConnectionUID=" + uid);
    
            }
    
        connection.setRequestMethod(method);
    
        connection.setRequestProperty("Accept","text/html, image/jpg, image/jpeg, image/,image/gif");
    
        int responseCode = connection.getResponseCode();
        if (responseCode != HttpConnection.HTTP_OK) {
        screen.requestFailed("Unexpected response code: " + responseCode);
        connection.close();
        return;
        }
        final String contentType = connection.getHeaderField("Content-type");
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        InputStream responseData = connection.openInputStream();
        byte[] buffer = new byte[10000];
        int bytesRead = responseData.read(buffer);
        while(bytesRead > 0) {
        baos.write(buffer, 0, bytesRead);
        bytesRead = responseData.read(buffer);
        }
        baos.close();
        connection.close();
    
                  UiApplication.getUiApplication().invokeAndWait(new Runnable() {
    
                        public void run() {
    
                            screen.requestSucceeded(baos.toByteArray(), contentType);
    
                        }
    
                        });
    
        } catch (IOException ex) {
        screen.requestFailed(ex.toString());
        }
    }
    

    The point here is that I have JSON and get the url of the thumbnail to fetch before add to listfield. The image should be ready in bitmap_temp but it still get null.

    UiApplication.getUiApplication().invokeAndWait(new Runnable() {
    
                                   public void run() {
    
                           getImageURL(thumb); 
    
                                 }});
    
    public void getImageURL(String url) {                HttpRequestDispatcher dispatcher2 = new HttpRequestDispatcher(url,                "GET", this);    }
    
    callback.insert(j.get("title")+" ", ""+get_htmlOff_first.trim(), bitmap_temp , temp_int_next , "Event");
    

    All day trying to fix it but no success, so I need help from you guys.

    Thank you

    "Is it possible to leave only 1 thread completely pick 10 pictures.

    Yes and this is how I would recommend that do you it this way.  So have a Thread that you give a list of things to do and let it work through each.

  • Get the image using getBinary

    Hello.. I try to extract the photo of a particular contact. I can see the built application in which this image is there but not able to fetch it. His donations illegal Argument Exception. I don't get what the problem... Here's the code... Please suggest where I m wrong?

    public static byte[] getPic(Contact contact) // This is the function for fetching byte data in the Picture class
        {
            byte[] pic = null;
            if(contact == null)
            {
                return null;
            }
            if((contact.countValues(Contact.PHOTO) > 0))
            {
                pic = new byte[(int)(contact.getBinary(Contact.PHOTO,0).length)];
                pic = contact.getBinary(Contact.PHOTO, 0);
            }
            return pic;
        }
    
    if(Picture.getPic(item)!=null) // item is the contact
    {
    EncodedImage image = EncodedImage.createEncodedImage(Picture.getPic(item), 0,
                            Login.getPic(item).length);
    }
    

    The createEncodedImage function does not work. I tried createBitmapFromBytes also. But who does not work too.

    Please suggest a solution.

    Thanx

    Drom the API documentation:

    "Note that the javadocs for addBinary(), setBinary(), getBinary() , and all say that binary data must be coded"into a string of 'B' binary code as defined by [IETF RFC 2047]". This means that the photo data returned by getBinary() will be coded in Base64. Also, the data can be specified to setBinary() and addBinary() in two bytes raw or encoded in base 64; If the raw bytes are specified then they are converted to Base64. To encode or decode Base64 data you can use Base64OutputStream or Base64InputStream, respectively. »

    In others, you will need to cancel first Base64 encoding.

  • Resize the SD card image to fit screen

    Hello

    I've already learned how to read a bitmap file from the SD card with the following code:

    public Bitmap getBitmapFromFile(String file){
    
        Bitmap b = null;
            try{
                FileConnection oInputFileConnection = (FileConnection)Connector.open(file, Connector.READ);
                InputStream oInputStream = null;
    
                if(oInputFileConnection.exists())
                    oInputStream = oInputFileConnection.openInputStream();
    
                byte[] arrData = new byte[(int)oInputFileConnection.fileSize()];
                int nCode = oInputStream.read(arrData, 0, arrData.length);
                oInputStream.close();
                oInputFileConnection.close();
    
                 b = Bitmap.createBitmapFromBytes(arrData, 0, -1, 1);
            }catch(Exception e){
    
            }
        return b;
    }
    

    Now I want to format this bitmap to the size 480x360px. How can I do?

    I know what I can change with this

    b = Bitmap.createBitmapFromBytes(arrData, 0, -1, 1);
    

    but it is not so accurate.

    Can someone help me?

    just tried it out.

    public class Utils {
        public static Bitmap resizeBitmap(Bitmap image, int width, int height)
        {   
    
            //Need an array (for RGB, with the size of original image)
            //
            int rgb[] = new int[image.getWidth()*image.getHeight()];
    
            //Get the RGB array of image into "rgb"
            //
            image.getARGB(rgb, 0, image.getWidth(), 0, 0, image.getWidth(), image.getHeight());
    
            //Call to our function and obtain RGB2
            //
            int rgb2[] = rescaleArray(rgb, image.getWidth(), image.getHeight(), width, height);
    
            //Create an image with that RGB array
            //
            Bitmap temp2 = new Bitmap(width, height);
    
            temp2.setARGB(rgb2, 0, width, 0, 0, width, height);
    
            return temp2;
        }
        private static int[] rescaleArray(int[] ini, int x, int y, int x2, int y2)
        {
            int out[] = new int[x2*y2];
            for (int yy = 0; yy < y2; yy++)
            {
                int dy = yy * y / y2;
                for (int xx = 0; xx < x2; xx++)
                {
                    int dx = xx * x / x2;
                    out[(x2 * yy) + xx] = ini[(x * dy) + dx];
                }
            }
            return out;
        }
    }
    
  • How to get the external Bitmap of URL object

    Hi all!

    I'm a developer starting with components of BlackBerry, I try to get a Bitmap of the outer object
    URL, but my getImage method does not work correctly. I think that the problem lies in the getImage method. just at the moment where I try to
    create form of Bitmap bytes. Note: J2me with the Image object, that it works!

    could someone help me please?

    Sorry for my bad English & thank you for helping me!

    Code:

    SerializableAttribute public class MainForm extends form {}

    private String url = "http://user-xxxx/json.js";
    private String [] imageURLs = new String [5];

    public MainForm() {}

    try {}
    getJSON (url);
    } catch (IOException e) {}
    e.printStackTrace ();
    }

    try {}
    Add (GetImage(this.imageURLs[0]));
    } catch (Exception e) {}
    e.printStackTrace ();
    }
    }

    Public Sub getJSON (String url) throws IOException {}
    StringBuffer sb = new StringBuffer();
    InputStream is = null;
    HttpConnection hc = null;
    try {}
    long bytesLength = 0;
    int ch = 0;
    HC = (HttpConnection), Connector.open (url);
    is = hc.openInputStream ();
    bytesLength = hc.getLength ();
    If (bytesLength! = - 1) {}
    for (int i = 0; i)< byteslength;="" i++)="">
    If ((ch = is.read (())! = - 1) {}
    SB. Append ((Char) ch);
    }
    }
    } else {}
    While ((ch = is.read (())! = - 1) {}
    bytesLength = is.available ();
    SB. Append ((Char) ch);
    }
    }
    parseJSON (sb.toString ());
    } {Finally
    is. Close();
    HC. Close();
    }
    }

    {} public void parseJSON (String sb)
    try {}
    JSONObject jo = new JSONObject (sb);
    If (jo! = null) {}
    JSONObject channel = jo.getJSONObject ("channel");
    If (channel! = null) {}
    JSONArray points = channel.getJSONArray("item");
    If (items! = null) {}
    for (int i = 0; i)< items.length();="" i++)="">
    JSONObject point = items.getJSONObject (i);
    this.imageURLs [i] = item.getString ("image");
    }
    }
    }
    }
    } catch (Exception e) {}
    e.printStackTrace ();
    }
    }

    I think that the problem lies in this method.

    public BitmapField getImage (String url) throws Exception {}
    InputStream inputStream = Connector.openInputStream (url) (InputStream);
    Bitmap image = null;
    BitmapField bf = null;
    try {}
    ByteArrayOutputStream Baos = new ByteArrayOutputStream();
    int ch;
    While ((ch = inputStream.read ())! = - 1) {}
    Baos.Write (ch);
    }
    Byte [] imageData = baos.toByteArray ();
    Image = Bitmap.createBitmapFromBytes (imageData, 0, imageData.length, 1);
    BF = new BitmapField (image);
    } {Finally
    If (inputStream! = null)
    inputStream.close ();
    }
    return (bf == null? null: bf);
    }

    public String [] getImageURLs() {}
    Return this.imageURLs;
    }

    }

    Finally my fatal mistake was in archive JSON, I change the URL of the images of http://localhost/image.jpg to
    http://user-xxx/image.jpg (MDS - CS available in http://localhost URL: 8080 /), and now it works!

    Ted and arkadyz, your suggestions have been very helpful for me, thank you very much!

    Final code:

    Class MainMIDlet

    Import net.rim.device.api.ui.UiApplication;

    SerializableAttribute public class MainMIDlet extends UiApplication {}

    public MainMIDlet() {}
    MainForm mf = new MainForm();
    pushScreen (mf);
    }

    Public Shared Sub main (String [] args) {}
    MainMIDlet mm = new MainMIDlet();
    mm.enterEventDispatcher ();
    }
    }

    Class MainForm

    import java.io.ByteArrayOutputStream.
    import java.io.IOException;
    import java.io.InputStream;

    Import javax.microedition.io.Connector;
    Import javax.microedition.io.HttpConnection;

    Import org.json.me.JSONArray;
    Import org.json.me.JSONObject;

    Import net.rim.device.api.system.EncodedImage;
    Import net.rim.device.api.ui.component.BitmapField;
    Import net.rim.device.api.ui.component.LabelField;
    Import net.rim.device.api.ui.container.MainScreen;

    SerializableAttribute public class MainForm extends form {}

    private String url = "http://user-xxx/json.js";
    private String [] jsonTitles = new String [5];
    private String [] jsonImages = new String [5];
    private LabelField lf = null;
    private BitmapField bf = null;

    public MainForm() {}

    try {}
    getJSON (url);
    } catch (IOException e) {}
    e.printStackTrace ();
    }

    LF = getLabelField(this.jsonTitles[0]);
    Add (LF);

    try {}
    BF = getBitmapField(this.jsonImages[0]);
    } catch (Exception e) {}
    e.printStackTrace ();
    }
    Add (BF);

    }

    Public Sub getJSON (String url) throws IOException {}
    StringBuffer sb = new StringBuffer();
    InputStream is = null;
    HttpConnection hc = null;
    try {}
    long bytesLength = 0;
    int ch = 0;
    HC = (HttpConnection), Connector.open (url);
    is = hc.openInputStream ();
    bytesLength = hc.getLength ();
    If (bytesLength! = - 1) {}
    for (int i = 0; i)< byteslength;="" i++)="">
    If ((ch = is.read (())! = - 1) {}
    SB. Append ((Char) ch);
    }
    }
    } else {}
    While ((ch = is.read (())! = - 1) {}
    bytesLength = is.available ();
    SB. Append ((Char) ch);
    }
    }
    parseJSON (sb.toString ());
    } {Finally
    is. Close();
    HC. Close();
    }
    }

    {} public void parseJSON (String sb)
    try {}
    JSONObject jo = new JSONObject (sb);
    If (jo! = null) {}
    JSONObject channel = jo.getJSONObject ("channel");
    If (channel! = null) {}
    JSONArray points = channel.getJSONArray("item");
    If (items! = null) {}
    for (int i = 0; i)< items.length();="" i++)="">
    JSONObject point = items.getJSONObject (i);
    this.jsonTitles [i] = item.getString ("title");
    this.jsonImages [i] = item.getString ("image");
    }
    }
    }
    }
    } catch (Exception e) {}
    e.printStackTrace ();
    }
    }

    public getLabelField (String title) {} LabelField
    LabelField lf = new LabelField (title);
    return of lf;
    }

    public BitmapField getBitmapField (String url) throws IOException {}
    InputStream is = Connector.openInputStream (url) (InputStream);
    BitmapField bf = null;
    try {}
    ByteArrayOutputStream Baos = new ByteArrayOutputStream();
    int ch;
    While ((ch = is.read (())! = - 1) {}
    Baos.Write (ch);
    }
    imageData Byte = baos.toByteArray ();
    BF = new BitmapField (EncodedImage.createEncodedImage (imageData, 0,))
    (imageData.length) .getBitmap ());
    } {Finally
    If (is! = null) {}
    is. Close();
    }
    }
    return (bf == null? null: bf);
    }

    }

  • InputStream.read in Curve 9300 does not completely read

    Hello!

    I am extracting data (an image) from a server, using HTTP and InputStream.

    In the Simulator, images are retrieved ok = 100,000 bytes

    Run the application in a BB 9300, recovers only 1129 bytes

    Can you advise how I can get the complete picture

    Here's the code for that

    HttpConnection httpConnection
    Try
    httpConnection = Connector.open (url) (HttpConnection)
    httpConnection.setRequestMethod (HttpConnection.POST)
    httpConnection.setRequestPropertyContent - type, application/x-www-formulaires-urlencode)
    httpConnection.setRequestPropertyUser - Agen, userAgent)
    httpConnection.setRequestPropertyContent - Languag, en - U)
    httpConnection.setRequestPropertyConnectio, closed)
    httpConnection.setRequestPropertyContent - Lengt, Integer.toString (postData.length ()))
              
    OutputStream oStrm = httpConnection.openOutputStream)
    oStrm.write (postData.getBytes ())
    oStrm.flush)
    oStrm.close)
              
    InputStream receive = httpConnection.openInputStream)
              
    data from Byte [] = new ubyte [150000]
    int dataLen = receive.read (data)
    Bitmap tmp = Bitmap.createBitmapFromBytes (data, 0, dataLen, 1);

    ...

    dataLen is over 100,000 in Simulator and 1129 in the camera.

    In this code, createBitmapFromBytes throws an exception.

    I had a teacher who said: "something is difficult if you spend a lot of time to discover that it was easy." And this is the case!

    Port 85 is blocked by default in BlackBerry Internet Service.

    So I configured Apache to listen to the two ports 8080 and 85, change the port to the BB app on 8080 and works!

    Thank you very much!

  • curve8900 image is reduced

    Hello

    I have an image (png), which has the same width as the display width. When viewing on the storm, the image fills the entire width of the screen, while on the curve8900, the image is reduced approximately 70% of its original width. So there's a very inexplicable.

    I tried the following:

    add(new BitmapField(Bitmap.createBitmapFromBytes(bytes, 0, bytes.length, 1)) );
    
    add(new BitmapField(Bitmap.createBitmapFromPNG(bytes, 0, bytes.length)) );
    
    add(EncodedImage.createEncodedImage(bytes, 0, bytes.length).getBitmap() );
    

    Any ideas?

    Thank you.

    Curve and the storm have both the physical width even, but the other resolutions. RexDoug thanks for your tip

  • loading images from an Sd Card

    Hello

    In my application I want pictures of the specified Sd folder.if map folder contain more than 10 images. It will take a long time to load all the images to display. For the loading of images from the SD card I worte code below.

    FileConnection con = null;
    try {}
    con = (FileConnection) Connector.open (path,
    Connector.READ_WRITE);
    con.setReadable (true);
    InputStream stream = con.openInputStream ();
    int ch;
    While ((ch = stream.read ())! = - 1) {}
    bytes. Append ((Char) ch);
    }
    } catch (Exception e) {}

    Byte [] imageBytes = new byte [bytes.length ()];
    imageBytes = bytes.toString () .getBytes ();

    Image bitmap = Bitmap.createBitmapFromBytes (imageBytes, 0,)
    (imageBytes.length, 6);

    to load all the images, it will take a long time to load. Y at - it no alternative to load all of the images on the wait.

    Have you tried to use other methods of reading...

  • Another problem in the BLOB view

    Hi all

    I have a problem in the image display on the screen. Here's my situation: I have an Oracle table, consists of string, CLOB and BLOB. I also have a web application using JSP and Servlet. My Blackberry application will access the servlet to get the data in my table. Returns an XML file, not a file JSP, servlet, then my Blackberry application will read this file, it displays on the screen. I use not BrowserField.

    My problem is... How can I display the image?

    I have tried to convert byteArray BLOB, and then again to convert to a string, inserting it into my XML. In my Blackberry app, get the string and convert it to byteArray and then use

    Bitmap.createBitmapFromBytes to get the Bitmap image. But it gives me nothing.

    Can someone help me?

    Thank you much in advance.

    Kind regards

    Novan Ananda

    I offer two General options:

    1 generate and send an image url to the XML format. Request per second to get the bytes of the images to the server. Server can presave the image in a temp folder or get the blob of the DB directly.

    2 send the image data as xml encoded in base64. Decode the device and view EncodedImage.

    I prefer the method if you send pictures not only in response. Can see the context for your asynchronous image download information.

    Thank you

    Eugen

  • How to save a bitmap on the device?

    Hello

    I have a bitmap image, which I have created a few bytes I get from server. Now, I want to save this file on my device. How can I achieve this?

    Thanks in advance

    That's how I saved my image on the device

    FileConnection fconn = (FileConnection)Connector.open("file:///store/home/user/screenCapture/image01.bmp",Connector.READ_WRITE);

    if(!fconn.) Exists())

    fconn. Create();

    OutputStream out = fconn.openOutputStream ();

    Bitmap image = Bitmap.createBitmapFromBytes(tempJpegBuffer,0,tempJpegBuffer.length,1);

    if(image == null)

    System.out.println ("null image");

    else {}

    out. Write (ReceiveThread.tempJpegBuffer);

    out. Close();

    }

    fconn. Close();

    } catch (Exception e) {}

    System.out.println ("Exception:" + try ());

    e.getMessage ();

    }

    and display the image recorded as by peter has mentioned above

    :-)

Maybe you are looking for

  • RAM HPG56 Notebook - beyond 3Gig?

    Hi all I have a laptop of 129WM of HPG56 for a child from the school.  It came stock with 3 GB of RAM.  Can I develop it and what? Enlargement will enhance the speed that is slower than now.  Also, I guess I should have corresponding to chip size tak

  • Qosmio G30-163: is it possible to get the HDMI by component

    Hello It seems that I'll be stuck with my Qosmio back to its own screen whenever I turn off my LCD TV. So what to do?I have a box of multiple component entry from another manufacturer. Is it possible to get the HDMI / component? While I listen to my

  • Cannot access admin or safe mode...

    Hi, I have a HP Pavilion dv2500 with a screen broken or burned. (My step grandson accidentally shot of the stool on which I got). I hung it on a monitor so that it can still be used and have since bought another.  I put the password on the admin acco

  • Speech recognition in Microsoft Word

    I just started using the Windows Vista built in the "Speech recognition" program and its working well except for one thing. I work everywhere (chat rooms, etc.) but not in my word processor (Microsoft Word, Microsoft Words or my internet Editor Tool)

  • Provision of storage optimizer &amp; Thin

    Well I use VOP for a bit, can someone tell me why and how I can get VOP watching the vs thin use commissioning / actual size put into service? And perhaps, to obtain a report on thin provisioning sizes? Perhaps a graph showing the growth of the provi