Pergunta

Can anyone know the way how to use createEncodedImage method of EncodedImage class in jde 4.5

Thanks and regards, Vivek Birdi

Foi útil?

Solução

Here's how you would do it if the Image was a resource file of the application:

byte[] imgData = null;
InputStream in = Application.getApplication().
        getClass().getResourceAsStream(imgName);
if(in == null) {
    // Handle appropriately
}

try {
    int length = in.available();
    imgData = new byte[length];
    in.read(bytes, 0, length);
} finally {
    in.close();
}

if(imgData == null) {
    // Handle appropriately
}

EncodedImage encodedImage = 
        EncodedImage.createEncodedImage(imgData, 0, imgData.length);

You could also pass a String as a parameter to define the MIME type. These are the supported MIME types:

  • "image/gif"
  • "image/png"
  • "image/vnd.wap.wbmp"
  • "image/jpeg" (supported only on Colour devices)
  • "image/jpg" (supported only on Colour devices)
  • "image/pjpeg" (supported only on Colour devices)
  • "image/bmp"
  • "image/tiff"

Finally, here's the documentation for 4.5: [EncodedImage Javadocs 4.5][1]

[1]: http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/system/EncodedImage.html#createEncodedImage(byte[], int, int)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top