Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JForum
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Devaka Cooray
Tim Cooke
Sheriffs:
Rob Spoor
Liutauras Vilda
paul wheaton
Saloon Keepers:
Tim Holloway
Tim Moores
Mikalai Zaikin
Carey Brown
Piet Souris
Bartenders:
Stephan van Hulst
Forum:
JForum
Removing the dependency on an X server.
Migrated From Jforum.net
Ranch Hand
Posts: 17424
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Use javax.imageio.ImageIO to read & write the images.
Use other than Graphics for resizing images, you can use this bicubic resize I wrote for my own project.
double ratioy=unscaledImage.getHeight() / (double)scaledImage.getHeight(); double ratiox=unscaledImage.getWidth() / (double)scaledImage.getWidth(); for( int y=0 ; y != scaledImage.getHeight() ; ++y ) { for( int x=0 ; x != scaledImage.getWidth() ; ++x ) { double r=0; double g=0; double b=0; double n=0; for( int y2=(int)Math.floor( y * ratioy ) ; y2 < Math.min( unscaledImage.getHeight() , Math.ceil( ( y + 1 ) * ratioy )) ; ++y2 ) { for( int x2=(int)Math.floor( x * ratiox ) ; x2 < Math.min( unscaledImage.getWidth() , Math.ceil( ( x + 1 ) * ratiox )) ; ++x2 ) { double weight=1; if( y2 < ( y * ratioy )) { weight*=y2 + 1 - ( y * ratioy ); } if( x2 < ( x * ratiox )) { weight*=x2 + 1 - ( x * ratiox ); } if( y2 > ( ( y + 1 ) * ratioy - 1 )) { weight*=( ( y + 1 ) * ratioy ) - y2; } if( x2 > ( ( x + 1 ) * ratiox - 1 )) { weight*=( ( x + 1 ) * ratiox ) - x2; } int c=unscaledImage.getRGB( x2 , y2 ); r+=((c >> 16) & 0xFF ) * weight; g+=((c >> 8) & 0xFF ) * weight; b+=((c >> 0) & 0xFF ) * weight; n+=weight; } } if( n != 0 ) { int c= 0xFF000000 | ((((int)( r / n )) & 0xFF) << 16) | ((((int)( g / n )) & 0xFF) << 8) | ((((int)( b / n )) & 0xFF) << 0); scaledImage.setRGB( x , y , c ); } } }
[originally posted on jforum.net by typo]
Migrated From Jforum.net
Ranch Hand
Posts: 17424
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
That's interesting!! very.
How well does the code performs?
Rafael
[originally posted on jforum.net by Rafael Steil]
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Colour picker, MouseDown(Event, int x, int y) Depreciation Help!
Graphics?????
Is there a better way to blend colors when painting with Graphics2D?
How to code a button with image
OO
More...