Here are my last 3 duke dollars. Can someone please help me draw a line?
I have been BEATING my head on this for well over a week now. I'm new to Java2D and I cannot find even one example of this simple little thing that I am trying to do. Not one.
All I want to do is draw an image, zoom that image, then draw some lines on that image, and then zoom it and have those lines show up where they should.
For example, we have an image which has been zoomed. No lines are yet drawn on it.
A line is added.
The image is then zoomed in or out one more time.
How do we get the line to remap to the newly zoomed image?
What I am doing is:
0) Load up an image from a file.
1) Create a zoomed image by using the Image.getScaledInstance() method.
2) Create a BufferedImage with the width and height of the image AFTER the zoom has taken place.
3) Create a Graphics2D object by the createGraphics from this BufferedImage.
4) Place the image into the BufferedImage by doing a BufferedImage.drawImage
5) Select two points to be the start and end of the line.
6) Draw the line using Graphics2D.drawLine(start.x, start.y, end.x, end.y).
7) Zoom the image again (using the Image.getScaledInstance() method.
8) Create a new ImageIcon using the image from above and override its paintIcon method like this:
ImageIcon newIcon = new ImageIcon(newImage) {
public void paintIcon(Component c, Graphics g, int x, int y)
super.paintIcon(c, g, x, y);
zoom(); //<---- ZOOM call
Now in the zoom routine, what do I need to do to get the lines to draw at the proper location and size?
Remember, the points of the lines (stored in a list as home grown line objects) are in screen coordinates, not image coordinates since they are just click points
Note that when I use these points to draw a line, all is well (the line gets drawn where it should), but I have problems when I zoom the image.
Thanks!
Below is the documentation and method signature of
Graphics.drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer);The important thing to note is that it does scaling on the fly if the size dictated by the source co-ordinates is defferent than the size dictated by the destination co-ordinates. The source image is always left un-touched.
So basically your visual data is located in an offscreen image. You can draw a line on that. Then create a new image, get it's graphics and call drawImage(original_image, co-ordinates that cause it to scale how you like).
Then you can draw lines on the 2nd image, create a 3rd, ...etc
* Draws as much of the specified area of the specified image as is
* currently available, scaling it on the fly to fit inside the
* specified area of the destination drawable surface. Transparent pixels
* do not affect whatever pixels are already there.
* <p>
* This method returns immediately in all cases, even if the
* image area to be drawn has not yet been scaled, dithered, and converted
* for the current output device.
* If the current output representation is not yet complete then
* <code>drawImage</code> returns <code>false</code>. As more of
* the image becomes available, the process that draws the image notifies
* the specified image observer.
* <p>
* This method always uses the unscaled version of the image
* to render the scaled rectangle and performs the required
* scaling on the fly. It does not use a cached, scaled version
* of the image for this operation. Scaling of the image from source
* to destination is performed such that the first coordinate
* of the source rectangle is mapped to the first coordinate of
* the destination rectangle, and the second source coordinate is
* mapped to the second destination coordinate. The subimage is
* scaled and flipped as needed to preserve those mappings.
* @param img the specified image to be drawn
* @param dx1 the <i>x</i> coordinate of the first corner of the
* destination rectangle.
* @param dy1 the <i>y</i> coordinate of the first corner of the
* destination rectangle.
* @param dx2 the <i>x</i> coordinate of the second corner of the
* destination rectangle.
* @param dy2 the <i>y</i> coordinate of the second corner of the
* destination rectangle.
* @param sx1 the <i>x</i> coordinate of the first corner of the
* source rectangle.
* @param sy1 the <i>y</i> coordinate of the first corner of the
* source rectangle.
* @param sx2 the <i>x</i> coordinate of the second corner of the
* source rectangle.
* @param sy2 the <i>y</i> coordinate of the second corner of the
* source rectangle.
* @param observer object to be notified as more of the image is
* scaled and converted.
* @return <code>true</code> if the current output representation
* is complete; <code>false</code> otherwise.
* @see java.awt.Image
* @see java.awt.image.ImageObserver
* @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
* @since JDK1.1
public abstract boolean drawImage(Image img,
int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
ImageObserver observer);
Similar Messages
-
This was happening all the time on my old 2006 iMac, and I thought that when I upgraded to a new computer it would go away. No such luck.
Sometimes the program works just fine, and other times I have this error. I haven't been able to pinpoint what is causing it.
Basically what happens is, I will try to type a number in the box to edit the size of the image (or sharpness, etc. something that requires you to enter a number), and as soon as my mouse hovers over the box, the numbers start changing on their own. As soon as I move the mouse away, the problem stops, but of course this means that I am unable to type in the number that I want.
I've tried unplugging my mouse and keyboard - that doesn't change anything.
Has anyone run into this issue before?
Btw, I use a 2013 iMac, OS version 10.9.5
(I have a video clip of this problem, but I don't know how to share it here)Your task is hardly a case for Photoshop: replacing text accurately in a scanned, not even
straightened image.
My recommendations:
a) put a crossreference list on each page
or
b) straighten the scans and improve the contrast, both by Photoshop.
Then apply a program which converts images of text into machine coded text
by OCR - Optical Character Recognition , for instance Abbyy Finereader
http://finereader.abbyy.de/professional/?adw=google_eu&gclid=CMirrcCMx7MCFZHRzAodlisAJg
(I'm not related to the manufacturer of this software, I'm just a user).
In coded text it's easy to replace isolated character groups as required.
Best regards and good luck --Gernot Hoffmann -
i have been trying to download the newest itunes to my windows 7 computer wit the last 2 wks now... im at the stage where iv tried everting from uninstalling itunes to installing it again... can someone please help before i throw the computer out the window!
Here is what worked for me:
My usb hub, being usb2, was too fast. I moved the wire to a usb port directory on my pc. That is a usb1 port which is slow enough to run your snyc. -
HI THERE,
CAN SOMEONE PLEASE HELP ME? I HAVE BEEN TRYING TO RESTORE MY IPHONE4 FROM IOS 4.3.3 TO 5.1.1 FOR THE LAST 6 HOURS AND EVERYTHING GOES THROUGH OK UNTIL IT GETS TO THE RESTORING IPHONE SOFTWARE, IT LOADS 1/2 THEN FREEZES. IVE LEFT IT LIKE THAT FOR AT 30MINS AND NOTHING HAPPENS. IVE TAKEN THE CORD OUT AND HAD TO TURN PHONE OFF AND RESTART, THEN LOAD IT BACK UP TO ITUNES ALL OVER AGAIN. MANY TIMES!!!!! IVE CHANGED CORD AND USB STILL NOTHING? IVE GOTTEN TO THE POINT WHERE I MAY HAVE RUINED IT ALTOGETHER AND NEED TO BUY A NEW PHONE? PLEASE I HOPE SOMEONE OUT THERE CAN HELP?:
MANY THANKSYou may not get a response as you are shouting at everyone.
All caps indicates shouting, is considered rude, and is difficult to read.
Many will not read such posts.
Try turning off you caps lock and asking again. -
I was using my wifi last night when I got an error message stating my ip address had been taken over. Then safari stopped working and i can no longer access the internet. I looked at my ip address and it states 000.000.000....can someone please help?
Sounds like a bogus pop up. In any case power down your Mac, your modem, your router. Then power back up in 1 minute sequence; modem, router, Mac.
-
I need to download all of my photos from my iPhone 4S and my iPad 2 to my MacBook Air because there is no more storage space available. I want to make sure all my photos are not lost and that they do not return to the original devices because of the cloud. Can someone please help ?
Connect your devices to the computer with the USB cable (one device at a time) and import the photos via iPhoto or Image Capture.
If you have not changed any default settings on your computer, iPhoto will automatically launch when you plug in the device. Then follow the import prompts. -
hhi guys
my video recording sounds not working at all but it's working for other things such as music. I've tried to clear my sound thing near the earphone hole but had no success can someone please help me out?Had an Iphone 4 for about 3 months now. This happened to the first one I had and they ended up having to replace it at the apple store just a couple weeks ago 6/2. It happened again last night to my new one. This time i was able to correct it by going to itunes, backing up the phone to icloud, and then restoring the software. Mine did not work with voice memo, but did work with headphones plugged in, and would also work on speaker. I could hear callers but they couldn't hear me. I had purchased a new case (lifeproof case at $79.99) because it comes with plugs that cover the headphone jack, and the charging port, and is also waterproof. I heard that the root cause is due to lint, dirt, etc getting inside the headphone jack. Well, must be something else. It's a 10 days old phone, and has been in this overpriced case the whole time, and I have not used the headphones. I hope this doesn't keep happening.
-
My itunes looks nothing like the examples in this tutorial. I do not have "display exact duplicates" or "date added". Can someone please help me remove duplicate songs? Also, I downloaded two audio books and they are showing up in my song list. Why???
'Show duplicates' is now under the 'View' menu. To see the 'Date added' column go to 'View options' from the 'View' menu and check it in the section under 'Stats'.
Click an audiobook once to select it and hit command-i (Mac) or control-i (Windows). Go to the 'Options' tab and set 'Media Kind' to 'Audiobook'. -
I have been using GRAB to capture screen displays. It has just stopped working since the last OSX Upgrade. Can anyone, please help restore functionality?
Thanks for that. I did as suggested but when I tried again, it still did not work. Another com.apple.Grab.plist appeared in the Library.
I now have the following files in Library
file://localhost/Users/peterpatel/Library/Preferences/com.apple.Grab.LSSharedFil eList.plist
file://localhost/Users/peterpatel/Library/Preferences/com.apple.Grab.LSSharedFil eList.plist.lockfile
file://localhost/Users/peterpatel/Library/Preferences/
file://localhost/Users/peterpatel/Library/Preferences/com.apple.Grab.plist.lockf ile
What do you suggest I do now? -
After Installing the OS x Mountain Lion some o the softwares are asking for Java SE 6 Runtime. Can someone please help me find a solution.
By default, ML no longer comes with the Java runtime preinstalled. I believe the route to enabling Java if you are going to need it is to run the Java Preferences app found in Utilities. It will inform you of Java's absence and offer to install the latest version and activate it. On subsequent runs, the Preferences app will allow you to fine tune how the runtime operates.
Note that the new default operation is for the applet plugin to be disabled. You need to enable it as needed and it self-deactivates if unused in awhile. Also important to note that Java comes in both 32 and 64 bit versions and you can set the preferred order. Default is 64-bit but I've had issues with some applets failing to run and have had to switch the order. -
PLEASE HELP ME. Some important emails have gone to an archive mail box and i really need them. Can someone please help me with how to view the archive email box and the emails that are in there?
http://kb.mozillazine.org/Recovering_deleted_mail_accounts
-
I have an ipod touch 4g. I did not have wifi for three days and when I came home my friends said they texted me when i didnt have signal. The messages i received when i did not have signal are not showing up. Can someone please help me?
You said "The messages i received when i did not have signal are not showing up."
How do you know received them?
If the sender got a message that the Messagers were not delivered than they were never delivered and the only way for you to get them is for the sender to resent them -
just update my mac it said "critical update" something like that so i updated and now my screen has like random dots all over and the colours are all messed up its like negative can someone please help?
Adds the ability to make and receive FaceTime audio calls
Adds call waiting support for FaceTime audio and video calls
Adds the ability to block incoming iMessages from individual senders
Improves the accuracy of unread counts in Mail
Resolves an issue that prevented Mail from receiving new messages from certain providers
Improves AutoFill compatibility in Safari
Fixes an issue that may cause audio distortion on certain Macs
Improves reliability when connecting to a file server using SMB2
Fixes an issue that may cause VPN connections to disconnect
Improves VoiceOver navigation in Mail and Finder
Provides a fix for SSL connection verification
this was the update
never said anything about the screen -
Can someone please help - I want to sync my icloud calendar with my iphone calendar. All of my entries from previous months are on my icloud calendar but not my iphone. How do I get them back on there? I have corrected my settings for future entries (I think/hope) but want to put the old stuff back on.
Try this...
Settings > Mail, Contact, Calendars. Scroll down to Calendars and set "Sync" as desired. -
First of all, I live in Ho Chi Minh City, Vietnam. Sometimes, I use a VPN to search on the web here. I purchased Toy Story 3 on my MacBook Pro 2011 OS/X - Lion through iTunes. I initially had trouble downloading it which may be due to being on and off the VPN but after a while it finally downloaded and shows up in my iTunes library on my MacBook.
Under my Apple ID account (which is the only Apple ID account I have), I look under purchase history and it shows that I paid for Toy Story which is where I got my Order # from. But if you go to the iTunes Store then to the Quick Links then click on Purchased, under all my Movies, it does NOT show Toy Story 3 as one of my movies.
Now when I go to my iPad (3rd gen.), Toy Story 3 does not show up under purchased movies (all or not on my iPad). It does not show up on my Apple TV as well. If I want to have Toy Story 3 on my iPad or Apple TV, then it says I have to purchase it again.
I have searched for help via Apple support communities but so far none of their solutions have worked for me. I have tried logging off iTunes & App Store on iPad and also shutting down the iPad. I also made sure that under iTunes Preferences>Store that iTunes in the Clouds purchases is checked. Can someone please help me with this? Your consideration is greatly appreciated. Thanks.Thanks King_Penguin for taking time to read and reply.
I just purchased this movie on Thursday, May 15, so just a few days ago. I have never had any trouble whatsoever since I have been in Vietnam. I have downloaded several movies and even music and they have all synced to my respected Apple products except for this purchase.
Sorry, I don't quite understand what you mean by studios and different versions. Could you please explain?
I checked my purchased list in my purchase history under my account and there are no hidden items.
Maybe you are looking for
-
Bar Charts with Non-Stacked Subgroups
I'm trying to create a report in CR2008 for my elementary school principals that will display how many students received a specific grade each of the three marking periods (T1, T2, and T3) per grade level per subject area (Math, PE, etc.). I was abl
-
User cannot retrieve data in app on local PC
A certain user cannot retrieve data in one application whilst being able to send data in that application. She can access the 'Finance' application, send data in that application and retrieve data but in another application, 'ICM', she cannot retriev
-
My Lumia 720 is giving me headache. Sometimes in the middle of reding or doing something, it freezes and you can't do anything even to switch off. It will freeze for few minutes and end up working when it feels like. Irritating.
-
Cisco Enterprise Attendant Console 8.0 - Second Console Queue
Hello Guys, We have 1 reception console in the head office and we want to setup 2nd reception console in different location (London). we have 2 operators license on CUEAC, I setup second operator with a seperat queue. We want to redirect the calls to
-
Role problems using RIMLoginModule
Hi all, we are currently trying to execute an web application using the RIMLoginModule with a blackberry. For this reason, we have to configure the module on: http://servername:port/webdynpro/dispatcher/sap.com/mba~com.sap.mbs.mso.main/MSOMain Unfort