Solved

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

Posted on 2004-04-10
4
352 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 20 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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
hibernate example issues from command prompt 10 66
Need help aligning JRadioButton that put in a box using GridBagLayout 2 27
Setup GlassFish 4 37
Coding for the first time 9 71
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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

696 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