The Artima Developer Community
Sponsored Link

Java Answers Forum
image "area selection" tool?

1 reply. Most recent reply: Apr 1, 2002 3:35 AM by David Wilfred Frederick

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a flat view of this topic  Flat View
Previous Topic   Next Topic
Threaded View: This topic has 1 reply on 1 page
david

Posts: 1
Nickname: bluetech
Registered: Mar, 2002

image "area selection" tool? Posted: Mar 26, 2002 11:27 PM
Reply to this message Reply
hello,

I am new to this board :). I am a Computer Science student...I was wondering how to implement a selection tool (a la Photoshop or Paint Shop Pro) within a java application.

So in an image, you could drag over a region, and it'd create an outline (your selection) of the region:

...so any info of how to generate the selection outline over an image?

...also one step beyond that would be how to pick off the x1, x2, y1, y2 from sed rectangular (or whatever) region....rectangles being my first choice for the area selection tool.

thnx a bunch!

Blue_Technx


Re: image "area selection" tool? Posted: Apr 1, 2002 3:35 AM
Reply to this message Reply
Posted by: David Wilfred Frederick    Posts: 1 / Nickname: wilfy / Registered: Apr, 2002
Hai,

Just use paint method to draw an Image(drawImage(img,x,z,obs))
and create a logic in ur paint method to draw a rect using mouselistener and mousemotionlistener
Like starting point(x1,y1) at mousepressed and ending point(x2,y2) at mouse released, it must be like
g.setColor(Color.red);
Rectangle selectionRect=new Rectangle(x1,y1,x2-x1,y2-y1);
g.drawRect(selectionRect);

Then use cropImage method to crop image of the about rectangle

ImageFilter filter=new CropImageFilter(selectionRect);
Image cropimg=createImage(new FilteredImageSource(img.getSource(),filter));


this is just a guide,

if u have doubts can contact me at david_cor@rediffmail.com

regards,
David


Topic: Reading cookies from applets Previous Topic   Next Topic Topic: question to Mr Jay Kandy

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use