Solved

Graphics::drawImage() quality

Posted on 2007-11-29
11
568 Views
Last Modified: 2008-02-01
Hi,

When i use the drawImage() function of Graphics, the output quality isn't that great. In win32, you can set some flags for interpolation type of the output image to the device context. Is there any parallel in java? I'd like to do a nicer interpolation than nearest neighbor (looks like that's what's being used)

Thanks
0
Comment
Question by:DJ_AM_Juicebox
[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
  • 5
  • 3
  • 3
11 Comments
 
LVL 92

Expert Comment

by:objects
ID: 20378072
0
 
LVL 92

Expert Comment

by:objects
ID: 20378077
0
 
LVL 92

Expert Comment

by:objects
ID: 20378088
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:DJ_AM_Juicebox
ID: 20378307
Yeah that seems to be what im looking for, but how could I store those values to use later - I want to do something like:

     Object m_ImageQuality = RenderingHints.VALUE_RENDER_BILINEAR;

     // Later on
     Graphics2D g2 = (Graphics2D)g;
     RenderingHints hints = g2.getRenderingHints();
     hints.put(RenderingHints.KEY_INTERPOLATION, m_ImageQuality);
     g2.setRenderingHints(hints);

but Im getting exceptions relating to m_ImageQuality - what type is that supposed to be?

Thanks
0
 
LVL 92

Expert Comment

by:objects
ID: 20378403
whats the error?
0
 

Author Comment

by:DJ_AM_Juicebox
ID: 20378422
Exception getting thrown, says invalid argument for:

     hints.put()
0
 
LVL 92

Expert Comment

by:objects
ID: 20378489
0
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 20378541
(I assume that your m_ImageQuality definition should be:
Object m_ImageQuality = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
?)
0
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 20378617
Your code works fine for me. I wonder if it's your runtime (there's no guarantee that all of the algorithms are implemented). Try this, and let us know if the exception persists:

Object m_ImageQuality = RenderingHints.VALUE_RENDER_DEFAULT ;
0
 
LVL 25

Accepted Solution

by:
InteractiveMind earned 500 total points
ID: 20378624
(I think you'll need to use the key  KEY_RENDERING  rather than  KEY_INTERPOLATION)
0
 

Author Comment

by:DJ_AM_Juicebox
ID: 20379089
ah yeah im being dumb, VALUE_RENDER_DEFAULT  had nothing to do with the interpolation schemes. I guess nearest neigbor is the default.

I think BILINEAR and BICUBIC are the same in my implementation, though I haven't examind the pixels programmatically. I'm surprised how slow it is.

Thanks!
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jsp insert to database example 2 85
wild fly 8 startup error 2 70
Java class and jar 3 55
Java ArrayList and if statement 2 49
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

742 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