开发者

What is BlackBerry's equivalent to Java ME's Image.createImage() from an existing (loaded) image

I have the following Java ME code that I'd like to port to BlackBerry:

Image imgAll = Image.createImage("/fontDigits_200x20.png");
imageDigits = new Image[10];
for(int i = 0; i < imageDigits.length; i++)
    imageDigits[i] = Image.createImage(imgAll, i * 20, 0, 20, 20, Sprite.TRANS_NONE);

Basically, it's one image of ten digits that I want to split into 10 individual images and store them into an array. I looked through the docs, but can't find anything similar on EncodedImage or Graphics.

开发者_开发技巧Thank you for any pointers!

UPDATE:

Good news! Apparently there's no way to crop an EncodedImage in such a way as to have a new EncodedImage which is a cropped subset of the original. However, you can do that with a Bitmap, which essentially is the same.


you can use

Bitmap.getARGB(int[] argbData,
                    int offset,
                    int scanLength,
                    int x,
                    int y,
                    int width,
                    int height)

after loading your image

Bitmap imgAll = Bitmap.getBitmapResource("fontDigits_200x20.png");

and off course you can create new Bitmap from this ARGB data.


You can do it directly with the Bitmap.scaleInto function:

Bitmap src;
Bitmap dst = new Bitmap(64,32);
int filterType = Bitmap.FILTER_BILINEAR;
src.scaleInto(srcLeft, srcTop, srcWidth, srcHeight, dst, dstLeft, dstTop, dstWidth, dstHeight, filterType);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜