Display.ScreenShot

I capture the screenshot and save it to the memory of handsets. But the image size is 0 bytes in size and when I open the image, a red x appears on the top left corner of the screen.

try convert image in bytes as:

PNGEncodedImage png = PNGEncodedImage.encode (screenshot);
final byte [] b = png.getData ();

If (b! = null) {}
try {}
FileConnection dirConn = (FileConnection) Connector.open (filePath, Connector.READ_WRITE);
If (! dirConn.exists ())
dirConn.mkdir ();

dirConn.close ();
} catch (Exception ex) {}
ex.printStackTrace ();
Dialog.Alert ("unable to download the file");
return;
}
String fileNm = filePath + file name;
try {}
FileConnection conn is Connector.open (fileNm, Connector.READ_WRITE) (FileConnection);.

If (conn.exists ()) {}
Conn.Delete ();
Conn.Create ();
} else {}
Conn.Create ();
}

conn.setWritable (true);
OutputStream out = conn.openOutputStream (0);

If (conn.canWrite ()) {}
out. Write (b, 0, b.length);
out. Flush();
out. Close();
Conn.Close ();
Dialog.Alert ("the saved Image");
NUM ++;
}
} catch (IllegalModeException e) {}
System.out.println ("IllegalModeException taking in the createFile method");
e.printStackTrace ();
} catch (SecurityException e) {}
without the permission of ' t create/write
System.out.println ("SecurityException caught in createFile method");
e.printStackTrace ();
} catch (IOException e) {}
System.out.println ("IOException caught in createFile method");
e.printStackTrace ();
} catch (Exception e) {}
System.out.println ("commissariats taken:" + e);
}
} else {}
Dialog.Alert ("file loading error");
return;
}
System.out.println ("* Bitmap pixel:" + bitmap.getBitsPerPixel ());
System.out.println ("* Bitmap height:" + bitmap.getHeight ());
           
}
};

Tags: BlackBerry Developers

Similar Questions

  • Display.screenshot does not behave as expected

    Hello

    The Display.screenshot method doesn't seem to work as expected. When I call this method, I got the dialog box asking the user or not to allow a screen capture to take. If the user selects Hello but leaves theDo ask not agai box unchecked, the screenshot is not taken. If, however, select 'allow' and check the box "Do not ask again" the screenshot is taken. Maybe that's a problem with the dialog box?

    Here is my code below-
    try {}
    Display.screenshot (this.bitmap, 0,0, Display.getWidth (), Display.getHeight ());
    }
    /**
    * If the user does not have a screen capture taken just display the General image
    */
    {} catch (ControlledAccessException cae)
    This.Bitmap = Constants.BACKGROUND_IMAGE;
    }

    Depends on how you code.

    Personally I d code it as follows:

    (a) have an indicator of persistent screenshot with three States

    0 - does not define

    -1 can't screenshot

    1 is allowed to the screenshot.

    Check this box if you are about to make a screenshot.  In this case - 1 indicate to the user that they have disabled this function be selected permissions.  If it's 0 or + 1, check the permissions API to see if you are allowed to do.  If you are, then set the value to 1 and do.  If you're not, tell them that they need to enable and display the permissions API.  When that is saved, check again.  If they helped him, set the indicator 1 and continue.  If they don't have not enabled it, it the value - 1 and tell them that you can't capture screens because they were disabled.

    Not sure which covers all cases, but you get the idea.

    Ok?

  • Upcoming context menu in the screenshot using Display.Screenshot

    Hi all

    I have a Menu item. When click on that I take screenshot, but I also get the context menu in the screenshot. I want only the screenshot to the screen behind the context menu.

    Pointers for this?

    Thanks in advance,

    Sandeep

    Thanks for you answers.

    I tried to have the timer also option to wait for a while before taking screenshot didn't work.

    Then I tried after option, it worked. I've added a call to repaint before taking a screenshot. Is this a good method to do?

    // Added this line before taking screenshot UiApplication.getUiApplication().repaint();
    Display.screenshot(bitmap,0,0,Display.getWidth(),Display.getHeight());
    

    I'll also explore the options mentioned by you.

    Thank you

    Sandeep

  • How close or minimize the menu box using Display.screenshot ()?

    Hello

    Did someone help out me in finding what way I can minimize or close the menu box while I take the screenshot of any screen?

    The problem is when I select the menu item Printscreen, the Display.Screenshot () method runs, and it takes the screenshot including the menu box that I opened for the selection of the menu-item (Printscreen).

    So, how to remove that box of Menu before you take the screenshot?

    Please answer

    Thank you.

    You might find some useful options in this thread;

    http://supportforums.BlackBerry.com/T5/Java-development/context-menu-coming-in-screenshot-by-using-D...

  • Display.screenshot (bitmap) returns white screen

    Hi all

    I develop an application that uses the camera (VideoControl and player).

    Here I am pasting my code

    String encoding = "encoding = video/3gpp & mode = standard;
    _player = Manager.createPlayer ("capture://video?" + coding);
    _player. Realize();

    _videoControl = (VideoControl) _player.getControl ("VideoControl");
    If (_videoControl! = null) {}
    Field videoField = _videoControl.initDisplayMode (Field) (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
    Add (videoField);
    btnStart = new ButtonField ("Get Snap", ButtonField.CONSUME_CLICK |) ButtonField.FIELD_HCENTER);
    Add (btnStart);
    _videoControl.setVisible (true);
    btnStart.setChangeListener (this);
    _player. Start();
    }

    On the click event of a btnStart buutonField I call it

    public void fieldChanged (field field, int x) {}
    Bitmap bmp = null;
    VerticalFieldManager vfmMain = new VerticalFieldManager)
    VerticalFieldManager.VERTICAL_SCROLL | VerticalFieldManager.VERTICAL_SCROLLBAR);
    While (snapCounter< 20)="">
    BMP = new Bitmap (Display.getWidth (), Display.getHeight ());
    Display.screenshot (BMP);
    vfmMain.add (new BitmapField (bmp));
    BMP = null;
    snapCounter ++;
    Thread.Sleep (100);
    }
    }

    bitmap HE I includes the pictures seen in the camera too.

    But it works fine when I run the application for the first tiem after installing it in the appliance.  When I get out the request and re-launch it he gives screen but without the camera images.  I want the image with the images of the camera.

    Please, someone knows why it's happening. And is there a solution for this.

    Thank you

    For this best prectice is to use the playerListener and overrride method.

    ' Public Sub playerUpdate (player pl, event of the string, eventData object) {}
    try {}
    I have if (event.equals (PlayerListener.STOPPED)) {}
    close the player
    _player. DEALLOCATE();
    _player. Close();
    } else {if (event.equals (PlayerListener.CLOSED))
    write your meeting
    }
    }
    } catch (Exception ex) {}
    System.out.println ("playerUpdate Exception" + ex.toString ());
    }
    }

    This works well.

    Now whenever it gives the page... with video...

  • Display.screenshot cause ControlledAccessException

    I developed an application that involves taking screen shots, using the Display.screenshot () method. It works very well in the Simulator, but I just tried to start a 8120 unit, and a ControlledAccessException is thrown by the method of screenshot. Cod files are signed with keys of the RIM and the device works OS 4.3.0.94, then as far as I can see that the method must be available. I get a lot of messages from the device by not saying "No sig 0 x 33" but as far as I know who is an in-house code of RIM signing key so I don't think that has anything to do with it. Does anyone know why it does not work on the device, but on the Simulator?

    You should check the effective permissions on the device.  Some of them may default on refuse, even if the application is signed.  This is because they represent a significant security risk on the device, event Injection (injection of keys) is one and so is browser filtering.  This may also be true for the screenshot on some devices.

    To check this setting for your application, go to Options-> advanced-> application Options and look for your application.  Once you find your app click menu and change the permissions.  Make sure of course not of them are defined on refuse, specifically screenshot under Interactions.

  • [PROBLEM] Cannot open my Skype program and connect. A bizarre version of plain html is displayed. (screenshot)

    That's what it appears to be:

    Please help, thnks!

    What you see is due to non-standard settings for the .css class in your Windows registry. You can solve this problem with a few simple steps:

    http://community.Skype.com/T5/Windows-desktop-client/Skype-issue/m-p/2126425#M204784

    See also this:

    http://community.Skype.com/T5/Windows-desktop-client/cannot-login-on-Skype/m-p/2960379#M237663

  • Screenshot on the torch

    Hello

    If I use this code to capture a screenshot on an OS 6 Toch:

    Display.screenshot(bmp);
    

    Then it works perfectly in vertical mode, but when I turn the camera in landscape mode and take a screenshot, then it gives me an illegalargumentexception. don't someone here on this?

    You create a new Bitmap every time? The dimensions are set correctly for the bitmap when you turn? In addition, there should be a message to the Exception, what is?

  • Convert Image screenshot of Bitmap file?

    I use code below to take the screenshot of Blackberry.

    public static Bitmap getScreenShot() {}
    Bitmap bitmap;
    image bitmap = new Bitmap (Display.getWidth (), Display.getHeight ());
    Display.screenshot (bitmap);
    try {}
    FileConnection file = (FileConnection)Connector.open("file:///store/home/user/img.bmp");
    {if(!file.) Exists())}
    leader. Create();
    }
    DataOutputStream out = file.openDataOutputStream ();
    out. Write (getBytesFromBitmap ());    Returns the bytes of the bitmap object
    } catch (IOException e) {}
    Generative TODO catch block
    e.printStackTrace ();
    }
    return bmp;
    }

    I want to convert this Bitmap object in a file of any format of file:.bmp/.png/.jpg etc. Is there a way I can achieve this?

    Help, please.

    Thank you.

    to solve this... I was without closing my outputstream...

  • Screenshot method

    Hi all

    I use the following code to capture screen:

    Bitmap image = new Bitmap( 64, 64 );                             Display.screenshot( image, 0, 0, 64, 64 );
    

    I then use:

    image.getType () which returns 197: ROWWISE_16BIT_COLOR

    But if I had to use

    Bitmap image = new Bitmap( 64, 64, Bitmap.ROWWISE_16BIT_COLOR );Display.screenshot( image, 0, 0, 64, 64 );
    

    He throws an IllegalArgumentException saying that is not supported

    Can someone explain this?

    Certainly if the created image is going to be a ROWWISE_16BIT_COLOR, then you can create a bitmap image in ROWWISE_16BIT_COLOR for the screenshot to use?

    According to the documents of the developer, the first parameter is the type where you should type and not in the last...

    Bitmap(int type, int width, int height)
    

    Given that the first parameter is 64, it shows that there is an illegal argument...

    See you soon...

  • I would get prominent display Btmap in a background application

    With JDE 4.5 I would read the Bitmap of the actual request screen and copy it to an image object to maintain and restore it later.

    I'm doing it in separate tread of tha request. So far, just found routiens to write on the screen, but don't not read.

    Display.screenshot

  • Screenshot using touchscreen devices

    Hello friends,

    I and requirement to capture the screenshot of blackberry. I can do this using the class net.rim.device.api.system.Display as follows:

    Bitmap screenBitmap=new Bitmap(Display.getWidth(),Display.getHeight());
    Display.screenshot(screenBitmap);
    

    But in the case of devices with touchscreen when the on-screen keyboard is visible the code above only takes the screenshot of the screen above the on-screen keyboard and not to take the screen shot of the on-screen keyboard.

    So I ask your valuable comments on how I can get the screenshot of the full screen, including the on-screen keyboard when it is visible.

    Thanks and greetings

    Ludovic P

    Hello Michael, thank you very much, the code you posted has worked perfectly

    I've never looked on this method.

    Thanks a lot again

  • Copy a screenshot in a Bitmap image does not work on a device

    I have developed a program that creates a Bitmap and copys a screenshot inside.

    This works on the 8820 Simulator, but not on firmware 8820 4.5.0.37.

    It throws the exception on the device. I think I need to know what kind of Bitmap must be created before you take the screenshot. There's a Constuctor Bitmap with a type parameter. Do I need to use it to create the correct Bitmap?

    Following is the screenshot:

    Bitmap TheBitMap = new Bitmap (Display.getWidth (), Display.getHeight ());
    Display.screenshot (theBitMap);

    Thank you Jürgen

    I rebooted the BlackBerry, deleted and reinstalled the application.

    Then the Exception disappears so the problem just magically disappeared.

  • IPhone 3.5 screenshots

    Apple support:

    Therefore apple itunes connect requiring 3.5 screenshots iphone, as well as screenshots of iphone 4 "?

    My folio is formatted for 4 "only?

    IOS8 Apple supports the iPhone 4S (3.5 ") requires so screenshots for the same thing.

    According to Apple iTunes connect Developer Guide, if your application supports the iPhone then you must download screenshots of 3.5-inch Retina Display and 4-inch Retina Display Screenshots, both marked as required.

    See: Properties to ITunes Connect App properties screenshot

    Thank you

    Earthling Vinod

  • How to convert the object Bitmap to byteArray.

    Hi all

    I had a problem in the conversion of the bitmap object to. BMP file.

    (Real need: capture the screen shot and convert that turned to the screen.) BMP image and I have to keep this image in the SCARD

    I shouldn't use any PNGEncodedImage or JPEGEncodedImage )

    I capture the screen shot using the

    Bitmap BM = new Bitmap (width, height);

    Display.screenshot (WB);

    to get the data from [] bytes of this bitmap object that I use

    Byte [] _bytes = getBytesFromBitmap (bitmap);

    public byte [] getBytesFromBitmap (Bitmap bmp) {}
    try {}
    int height = bmp.getHeight ();
    int width = bmp.getWidth ();
    int [] rgbdata = new int [width * height];
    ByteArrayOutputStream Bos = new ByteArrayOutputStream();
    DataOutputStream back = new DataOutputStream (bos);
    Graphics g = new Graphics (bmp);
    bmp.getARGB(rgbdata,0,width,0,0,width,height);
    for (int i = 0; i)< rgbdata.length="" ;="" i++)="">
    If (rgbdata [i]! = - 1) {}
    dos.writeInt (i);
    back. Flush();
    //l++;
    }
    }
    Bos.Flush ();
    Return bos.toByteArray ();
    }
    catch (Exception ex) {}
    Dialog.Alert ("getBytesFromBitmap:" + ex.toString ());
    Returns a null value.
    }

    If I use this byte array in the Sub statement I get the "IllegalArgumentException".

    BMPEncodedImage.createEncodedImage (_bytes, 0, _bytes .length);

    all can help me how I can get the byte [] data from the bitmap object?

    import java.io.ByteArrayOutputStream;import java.io.DataOutputStream;import java.io.IOException;
    
    import javax.microedition.lcdui.Image;
    
    /** * @author Samuel Halliday */public final class BMPGenerator {
    
        /**     * @param image     * @return     * @throws IOException     * @see {@link #encodeBMP(int[], int, int)}     */    public static byte[] encodeBMP(Image image) throws IOException {        int width = image.getWidth();        int height = image.getHeight();        int[] rgb = new int[height * width];        image.getRGB(rgb, 0, width, 0, 0, width, height);        return encodeBMP(rgb, width, height);    }
    
        /**     * A self-contained BMP generator, which takes a byte array (without any unusual     * offsets) extracted from an {@link Image}. The target platform is J2ME. You may     * wish to use the convenience method {@link #encodeBMP(Image)} instead of this.     * 

    * A BMP file consists of 4 parts:- *

      *
    • header
    • *
    • information header
    • *
    • optional palette
    • *
    • image data
    • *
    * At this time only 24 bit uncompressed BMPs with Windows V3 headers can be created. * Future releases may become much more space-efficient, but will most likely be * ditched in favour of a PNG generator. * * @param rgb * @param width * @param height * @return * @throws IOException * @see http://en.wikipedia.org/wiki/Windows_bitmap */ public static byte[] encodeBMP(int[] rgb, int width, int height) throws IOException { int pad = (4 - (width % 4)) % 4; // the size of the BMP file in bytes int size = 14 + 40 + height * (pad + width * 3); ByteArrayOutputStream bytes = new ByteArrayOutputStream(size); DataOutputStream stream = new DataOutputStream(bytes); // HEADER // the magic number used to identify the BMP file: 0x42 0x4D stream.writeByte(0x42); stream.writeByte(0x4D); stream.writeInt(swapEndian(size)); // reserved stream.writeInt(0); // the offset, i.e. starting address of the bitmap data stream.writeInt(swapEndian(14 + 40)); // INFORMATION HEADER (Windows V3 header) // the size of this header (40 bytes) stream.writeInt(swapEndian(40)); // the bitmap width in pixels (signed integer). stream.writeInt(swapEndian(width)); // the bitmap height in pixels (signed integer). stream.writeInt(swapEndian(height)); // the number of colour planes being used. Must be set to 1. stream.writeShort(swapEndian((short) 1)); // the number of bits per pixel, which is the colour depth of the image. stream.writeShort(swapEndian((short) 24)); // the compression method being used. stream.writeInt(0); // image size. The size of the raw bitmap data. 0 is valid for uncompressed. stream.writeInt(0); // the horizontal resolution of the image. (pixel per meter, signed integer) stream.writeInt(0); // the vertical resolution of the image. (pixel per meter, signed integer) stream.writeInt(0); // the number of colours in the colour palette, or 0 to default to 2n. stream.writeInt(0); // the number of important colours used, or 0 when every colour is important; // generally ignored. stream.writeInt(0); // PALETTE // none for 24 bit depth // IMAGE DATA // starting in the bottom left, working right and then up // a series of 3 bytes per pixel in the order B G R. for (int j = height - 1; j >= 0; j--) { for (int i = 0; i < width; i++) { int val = rgb[i + width * j]; stream.writeByte(val & 0x000000FF); stream.writeByte((val >>> 8 ) & 0x000000FF); stream.writeByte((val >>> 16) & 0x000000FF); } // number of bytes in each row must be padded to multiple of 4 for (int i = 0; i < pad; i++) { stream.writeByte(0); } } byte[] out = bytes.toByteArray(); bytes.close(); // quick consistency check if (out.length != size) throw new RuntimeException("bad math"); return out; } /** * Swap the Endian-ness of a 32 bit integer. * * @param value * @return */ private static int swapEndian(int value) { int b1 = value & 0xff; int b2 = (value >> 8 ) & 0xff; int b3 = (value >> 16) & 0xff; int b4 = (value >> 24) & 0xff; return b1 << 24 | b2 << 16 | b3 << 8 | b4 << 0; } /** * Swap the Endian-ness of a 16 bit integer. * * @param value * @return */ private static short swapEndian(short value) { int b1 = value & 0xff; int b2 = (value >> 8 ) & 0xff; return (short) (b1 << 8 | b2 << 0); } } Found form the Link mentioned below:
    http://javablog.co.uk/2007/12/26/j2me-bitmap-encoder/

Maybe you are looking for

  • No MMS messaging?

    Can't find the settings for MMS messaging. And he will receive none. It didn't he? Sorry for this noobish question.

  • Skype crashing whenever I start it.

    After that I updated to Skype to the newest one, it crashes whenever I start it. I tried to look for further discussions on this forum and tried like 50 different things (IE cleaning, decommissioning, IE, etc etc) now the problem is, Skype 6.14 works

  • Impossible to update Windows 7 error Code 0x80070005

    Hello. I've been having this problem for a few weeks, I have Windows 7 Ultimate on my laptop and suddenly Windows Update stopped application updates, the "loading bar" on the windows update window is never ending search for updates for my computer. H

  • HELP 0X0000007E

    I get the blue screen stop: 0x0000007E (0XFFFFFFFFC0000005, 0XFFFFF880010676B0, 0XFFFFF8800397E868, 0XFFFFF8800397E0C0) A local technician told me that my computer was useless and that I had to buy another one, is it true? is there a solution for thi

  • Paint screen

    I use the constructor for screen drawing several bitmaps on a graph and then by loading these have a bitmapfield and finally add to the screen using add (BitmapField). Now, I want to be able to change the bitmap image that I drew on the graph and rep