?
Solved

how to convert an image type of object in java a buffered image

Posted on 2004-04-10
4
Medium Priority
?
366 Views
Last Modified: 2006-11-17
hi,

i am trying to read a bmp file and convert it to three dimensional array of brightness, i have got it converted to image, now how can i convert it to bufferedimage object in java????

0
Comment
Question by:kashish_18_2003
  • 3
4 Comments
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 10797422
> three dimensional array of brightness
do you mean the RGB values?

> now how can i convert it to bufferedimage object in java?
you have 2 solutions here
1) you read your image file straigth to a BufferedImage using ImageIO static read method.
2) you create your BufferedImage, use the getGraphics() method to get it's graphics object and paint you Image on the graphics object.

solution 1 is much easier.
0
 

Author Comment

by:kashish_18_2003
ID: 10797857
sorry, 2d array of brightness... not rgb values,

i want a .bmp file to be read but io allows only jpeg, gif and png files, i have read it to a image file format now for rgb val i can use pixel grabber but what abt brightness, i want brightness vals.
0
 
LVL 30

Accepted Solution

by:
GrandSchtroumpf earned 60 total points
ID: 10801004
You can calculate the brightness from the RBG values.
This formula seems to be often used:
30% red + 59% green + 11% blue
But the result is debatable:  http://www.compuphase.com/cmetric.htm

For your BufferedImage, your can use the second solution i suggested:

    int imageType = BufferedImage.TYPE_BYTE_INDEXED;
    BufferedImage newImage = new BufferedImage(yourImageWidth, yourImageHeight, imageType);
    java.awt.Graphics2D destG = newImage.createGraphics();
    destG.drawImage(yourImage, 0, 0, null);
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 10980894
:°)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month16 days, 15 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question