Solved

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

Posted on 2004-04-10
4
351 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 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
object oriented programming comparison 5 77
xampp tool 12 56
oracle 11g 23 106
How  can  i  resolve  HTTP Status 404 -? 8 41
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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.

809 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