Solved

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

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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

688 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