Results 1 to 4 of 4
Thread: scaling image
- 05-06-2010, 05:23 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 41
- Rep Power
- 0
scaling image
hi,
i need to print a page which contains a picture. Well, everything working correct but i am missing one thing.
I am scaling an image that will fit an A4 size paper. and the next line, i am bringing up the print dialog screen. but the problem is, when the dialog screen appears, it causes the scaling process stop, and when i say print, the picture doesnt appear.
but when i do the scale image with another button(just to test) and wait around 2-3 seconds, and then when i print the page, it's ok.
i need to check the status of the scaling process before i bring up the print dialog but i couldnt manage it..
here is my code
is there a way that i can check the status of "scaling" process. i was thinking maybe when i sayJava Code:Map4Print = ScaleImage(findPath.bufferResim, 500,500); //the picture that i want to print. PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(new newprintjob()); boolean doPrint = job.printDialog(); if (doPrint) { try { job.print(); ShowDialogBox("Print","Printing is in proccess. Please wait for a while.",JOptionPane.INFORMATION_MESSAGE); } catch (PrinterException e) { ShowDialogBox("Print Error",e.getMessage(),JOptionPane.WARNING_MESSAGE); } }
it would give me null coz it's not scaled yet, but it does give me the address.. :oJava Code:Image original = resim; bufferResim = original.getScaledInstance(targetComponent.getWidth(), targetComponent.getHeight(), Image.SCALE_FAST); System.out.println(bufferResim);
thanks :)
- 05-06-2010, 08:28 PM #2
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
You mean direction? :rolleyes:
Well you can simply redraw your image with new params ...
And not to miss its scale use some coefficient value like aJava Code:public void paintComponent(Graphics g){ g.drawImage(...,new_width,new_height,...); }
Java Code:int new_width=width+(width*100/coeff);
If my answer helped you. Please click my "REP" button and add a comment
Have a Good Java Coding :)
- 05-07-2010, 12:44 AM #3
Member
- Join Date
- Mar 2010
- Posts
- 41
- Rep Power
- 0
thanks for the reply..
well, you know if we don't initialize any variable, it would return "null". So i was thinking that my image variable could return null too if the scale proccess doesnt end. so i could make a check like
while the variable is null, wait for it to be assigned value... something like that. but it doesnt, so never mind it..
it's just i need to wait between two lines for my scale proccess to be completed. but while waiting, the app should be scaling the image instead of just waiting..Last edited by OmerHalit; 05-07-2010 at 12:47 AM.
- 05-07-2010, 01:30 AM #4
Member
- Join Date
- Mar 2010
- Posts
- 41
- Rep Power
- 0
well, i got my answer with my trials :)
let me share with you too..
i have noticed that if the image is not scaled yet, the getheight method would being -1.
so, i made i check like this
the value of variable i will change. i got 65 for the first click and 19 for the third click.. it worked well.. (so far :D )Java Code:Image original = resim; PrintableMap = original.getScaledInstance(450, 450, Image.SCALE_SMOOTH); int i = -1; do{ System.out.println(++i); System.out.println(PrintableMap.getHeight(this)); } while(PrintableMap.getHeight(this) == -1);
Similar Threads
-
AWT scaling the window to the thing that is painted
By chappa in forum AWT / SwingReplies: 16Last Post: 01-04-2010, 06:34 PM -
Scaling a JPEG
By ScottVal in forum Advanced JavaReplies: 5Last Post: 03-21-2009, 08:47 PM -
Scaling-ache and mouse dragging
By willemjav in forum Java AppletsReplies: 19Last Post: 07-19-2008, 12:17 AM -
scaling images
By willemjav in forum Java AppletsReplies: 7Last Post: 06-19-2008, 09:54 AM -
Converting multiple banded image into single banded image... Image enhancement
By archanajathan in forum Advanced JavaReplies: 0Last Post: 01-08-2008, 05:29 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks