开发者

Open a bitmap with Inputstream

How would I open a bitmap with Inputstream?

e.g InputStream inputStream = 开发者_运维问答image where image is of type Bitmap?

Thanks.


To read the bitmap image in your app,
BufferedImage img = ImageIO.load("mybitmap.bmp");

To get the pixels from the buffered image object, use getRGB()

int[] pixels = img.getRGB(0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth());

javadoc for getRGB().

For more info, see this article.


InputStream is = new BufferedInputStream(new FileInputStream("source.bmp"));

Is this what you need ?


            if (thumbnail != null) {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                thumbnail.compress(Bitmap.CompressFormat.PNG, 100, baos);
                inputstream = new ByteArrayInputStream(baos .toByteArray());
            }

try this

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜