Solved

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

Posted on 2004-04-10
4
346 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
Comment Utility
> 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
Comment Utility
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
Comment Utility
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
Comment Utility
:°)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now