关于Blackberry中的EncodedImage

时间:2011-06-30 10:31:59

标签: blackberry

假设我在BlackBerry JDE中的项目中添加了动画GIF图像名称 test.GIF ,以便在AnimatedGIFField类中使用。现在我需要将其转换为编码图像。  在参考文献中,它给出了编码图像的以下功能

public static EncodedImage createEncodedImage(byte [] data,                                               int offset,                                               int length)

Plz给我代码将test.GIF转换为编码图像????

2 个答案:

答案 0 :(得分:1)

使用此代码

EncodedImage encImg = GIFEncodedImage.getEncodedImageResource("test.gif");

如果您需要GIFEncodedImage,请将encImg投射到GIFEncodedImage

GIFEncodedImage img = (GIFEncodedImage) encImg;

答案 1 :(得分:0)

顺便说一句,在OS7上将 EncodedImage 强制转换为 GIFEncodedImage 会失败。您必须将gif扩展名重命名为 .agif 才能使其正常工作。