Zooming the selected rectangle on an image

hi,
my problem is that once i'm able to zoom my image ,if i want to zoom it further either on mouse click or selecting a rectangle again on mousedrag,it throws an exception coz i'm not able to get either size or bofferedimage from the once zoomed image.
do u have any suggestions:
i'm sending my latest code
private Graphics2D createGraphics2D(int w, int h) {
Graphics2D g2 = null;
if (bimg == null || bimg.getWidth() != w || bimg.getHeight() != h) {
bimg = (java.awt.image.BufferedImage) createImage(w, h);
g2 = bimg.createGraphics();
g2.setBackground(getBackground());
g2.clearRect(0, 0, w, h);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
return g2;
public void update(Graphics g) {
paint(g);
public void paint(Graphics g) {
super.paint(g);
try{
t=new AffineTransform();
//////added 09aug
Dimension d = getSize();
System.out.println(d);
if(!first_paint){
setScale(d.width,d.height - DRG_YPOS);
first_paint = true;
if(!image1)
Graphics2D g2 = createGraphics2D(d.width, d.height -DRG_YPOS);
g2.translate(((d.width/2) - ((zoomx*maxx + zoomx*minx)/2))
+ zoomx*scrollx,
(((d.height-DRG_YPOS)/2))+scrolly);
g2.scale(zoomx,zoomy);
draw(d.width, (int)(maxy - (maxy- miny)/2) , g2);
g.drawImage(bimg, 0, DRG_YPOS, this);
System.out.println("image drawn for the "+counter+"time");
counter++;
System.out.println("counter is"+counter);
System.out.println("image1 is"+image1);
file://t= g2.getTransform();
if(fzoom1)
g.setColor(Color.red);
g.drawRect(beginX,beginY,end1X-beginX,end1Y-beginY);
System.out.println("drawing rect");
if(fzoom){
wx=beginX;
wy=beginY;
ww=end1X-beginX;
wh=end1Y-beginY;
bi = bimg.getSubimage(wx,wy,ww,wh);
System.out.println("hello 2d");
System.out.println(wx+","+wy+","+ww+","+wh);
Dimension d1=getSize();
Graphics2D g2d = bi.createGraphics();
// g2d.setBackground(getBackground());
int w=500;
int h=500;
System.out.println(w+","+h);
System.out.println("g2d"+g2d);
System.out.println("settransform callrd");
// zoomFactor *=1;
g2d.translate(100.0f, 100.0f);
g2d.scale(zoomFactor, zoomFactor);
System.out.println("scale called"+zoomFactor);
file://zoomFactor++;
g.drawImage(bi,50,50,w,h,this);
System.out.println("w,h,bi"+w+","+h+","+bi);
file://repaint();
image1=true;
file://zoomFactor++;
file://fzoom=false;
g2.dispose();
}catch(Exception e)
System.out.println("exception"+e);
class IMS2DFrameMouseAdapter extends MouseAdapter implements MouseMotionListener{
int mx;
int my;
int endx,endy;
int X;
int Y;
Point point;
public void mouseClicked( MouseEvent event ) {
if(select)
Dimension d = getSize();
AffineTransform at = new AffineTransform();
at.setToIdentity();
at.translate(((d.width/2) - ((zoomx*maxx + zoomx*minx)/2))
+ zoomx*scrollx,
(((d.height-DRG_YPOS)/2))+scrolly);
at.scale(zoomx,zoomy);
Point src = new Point(event.getX(),event.getY() - DRG_YPOS);
Point pt = new Point();
try{
at.inverseTransform( src, pt);
catch( NoninvertibleTransformException e)
e.printStackTrace();
pt.setLocation(pt.getX(), (maxy - (maxy- miny)/2 - pt.getY()));
hitObject(pt);
/*if(fence_zoom){
fzoom2=true;
}else
fzoom2=false;
public void mousePressed( MouseEvent event ) {
if(fence_zoom)
System.out.println("mouse Pressed");
beginX = event.getX();
beginY = event.getY();
repaint();
public void mouseReleased( MouseEvent event ) {
end1X = event.getX();
end1Y = event.getY();
System.out.println("ENDX---"+endx);
System.out.println("endy-----"+endy);
if(translation)
translatedrawing(endx - startx,endy - starty);
if(fence_zoom){
System.out.println("mouse released");
file://end1X = event.getX();
// end1Y = event.getY();
fzoom=true;
repaint(); file://updateSize(event);
else{
fzoom=false;
public void mouseDragged(MouseEvent event) {
if(fence_zoom){
end1X = event.getX();
end1Y = event.getY();
fzoom1=true;
System.out.println("mouse dragged");
repaint();
else {
fzoom1=false;
public void mouseMoved(MouseEvent event)
thanks
sangeeta
"Gustavo Henrique Soares de Oliveira Lyrio" wrote:
I think you are using the wrong drawimage method. If you have the selection retangle coordinates, you will need a method that draw this selection in a new retangle selection (your canvas or panel)
Where goes my paintMethod:
protected void paintComponent(Graphics g)
g.drawImage(image, START_WINDOW_X, START_WINDOW_Y, WINDOW_X, WINDOW_Y, px1, py1, px2, py2, this);
Take a look in the drawimage methods in the java web page. I think it will help.
[]`s
Gustavo
----- Original Message -----
From: sangeetagarg
To: Gustavo Henrique Soares de Oliveira Lyrio
Sent: Thursday, August 16, 2001 9:14 AM
Subject: Re: Re: re:zoom in 2d
i'm sending u the paint method.but still i'm not able to select the desired area .it zooms the while image.tell me if there is any error in the code.
file://if(fence_zoom)
if(fzoom1 )
if (currentRect != null) {
System.out.println("hello");
g.setColor(Color.white);
g.drawRect(rectToDraw.x, rectToDraw.y,
rectToDraw.width - 1, rectToDraw.height - 1);
System.out.println("drawing rectangle");
fzoom1=false;
if(fzoom)
bi = bimg.getSubimage(rectToDraw.x, rectToDraw.y, rectToDraw.width, rectToDraw.height);
System.out.println(rectToDraw.x+","+ rectToDraw.y+","+rectToDraw.width+","+ rectToDraw.height);
Graphics2D g2d = bi.createGraphics();
g2d.setBackground(getBackground());
g2d.clearRect(0, 0,0,0 );
file://ZoomIn();
file://t= g2d.getTransform();
file://g2d.setTransform(t);
System.out.println("settransform callrd");
// zoomFactor *=1;
g2d.translate(100.0f, 0.0f);
g2d.scale(zoomx, zoomy);
System.out.println("scale called"+zoomFactor);
zoomx += ZOOMSTEP;
zoomy += ZOOMSTEP;
file://zoomFactor+=zoomFactorupdate;
g.drawImage(bi, 0, 0, this);
// g.drawImage(bi,10,10,this);
repaint();
fzoom=false;
thanks
sangeeta

Display first your image on an invisible label. Once displayed you can get the size of the image and you can redimension it as you want.
Bye Alessio

Similar Messages

  • Zoom the selected area in an image!!

    hi all,
    i heve created a an application in which user can select an area and on an image and then zoom that particular portion but when i zoom it the image keeps on going to the right bottom corner of the screen.I want my zoom to keep the selected area in the center of the screen.can anybody help me in thet.
    thanks
    sangeeta

    hi,
    can u solve ome more problem for me as u seem to be very comfortable in 2d.my problem is that once i'm able to zoom my image ,if i want to zoom it further either on mouse click or selecting a rectangle again on mousedrag,it throws an exception coz i'm not able to get either size or bofferedimage from the once zoomed image.
    do u have any suggestions:
    i'm sending my latest code
    private Graphics2D createGraphics2D(int w, int h) {
    Graphics2D g2 = null;
    if (bimg == null || bimg.getWidth() != w || bimg.getHeight() != h) {
    bimg = (java.awt.image.BufferedImage) createImage(w, h);
    g2 = bimg.createGraphics();
    g2.setBackground(getBackground());
    g2.clearRect(0, 0, w, h);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
    RenderingHints.VALUE_ANTIALIAS_ON);
    return g2;
    public void update(Graphics g) {
    paint(g);
    public void paint(Graphics g) {
    super.paint(g);
    try{
    t=new AffineTransform();
    //////added 09aug
    Dimension d = getSize();
    System.out.println(d);
    if(!first_paint){
    setScale(d.width,d.height - DRG_YPOS);
    first_paint = true;
    if(!image1)
    Graphics2D g2 = createGraphics2D(d.width, d.height -DRG_YPOS);
    g2.translate(((d.width/2) - ((zoomx*maxx + zoomx*minx)/2))
    + zoomx*scrollx,
    (((d.height-DRG_YPOS)/2))+scrolly);
    g2.scale(zoomx,zoomy);
    draw(d.width, (int)(maxy - (maxy- miny)/2) , g2);
    g.drawImage(bimg, 0, DRG_YPOS, this);
    System.out.println("image drawn for the "+counter+"time");
    counter++;
    System.out.println("counter is"+counter);
    System.out.println("image1 is"+image1);
    file://t= g2.getTransform();
    if(fzoom1)
    g.setColor(Color.red);
    g.drawRect(beginX,beginY,end1X-beginX,end1Y-beginY);
    System.out.println("drawing rect");
    if(fzoom){
    wx=beginX;
    wy=beginY;
    ww=end1X-beginX;
    wh=end1Y-beginY;
    bi = bimg.getSubimage(wx,wy,ww,wh);
    System.out.println("hello 2d");
    System.out.println(wx+","+wy+","+ww+","+wh);
    Dimension d1=getSize();
    Graphics2D g2d = bi.createGraphics();
    // g2d.setBackground(getBackground());
    int w=500;
    int h=500;
    System.out.println(w+","+h);
    System.out.println("g2d"+g2d);
    System.out.println("settransform callrd");
    // zoomFactor *=1;
    g2d.translate(100.0f, 100.0f);
    g2d.scale(zoomFactor, zoomFactor);
    System.out.println("scale called"+zoomFactor);
    file://zoomFactor++;
    g.drawImage(bi,50,50,w,h,this);
    System.out.println("w,h,bi"+w+","+h+","+bi);
    file://repaint();
    image1=true;
    file://zoomFactor++;
    file://fzoom=false;
    g2.dispose();
    }catch(Exception e)
    System.out.println("exception"+e);
    class IMS2DFrameMouseAdapter extends MouseAdapter implements MouseMotionListener{
    int mx;
    int my;
    int endx,endy;
    int X;
    int Y;
    Point point;
    public void mouseClicked( MouseEvent event ) {
    if(select)
    Dimension d = getSize();
    AffineTransform at = new AffineTransform();
    at.setToIdentity();
    at.translate(((d.width/2) - ((zoomx*maxx + zoomx*minx)/2))
    + zoomx*scrollx,
    (((d.height-DRG_YPOS)/2))+scrolly);
    at.scale(zoomx,zoomy);
    Point src = new Point(event.getX(),event.getY() - DRG_YPOS);
    Point pt = new Point();
    try{
    at.inverseTransform( src, pt);
    catch( NoninvertibleTransformException e)
    e.printStackTrace();
    pt.setLocation(pt.getX(), (maxy - (maxy- miny)/2 - pt.getY()));
    hitObject(pt);
    /*if(fence_zoom){
    fzoom2=true;
    }else
    fzoom2=false;
    public void mousePressed( MouseEvent event ) {
    if(fence_zoom)
    System.out.println("mouse Pressed");
    beginX = event.getX();
    beginY = event.getY();
    repaint();
    public void mouseReleased( MouseEvent event ) {
    end1X = event.getX();
    end1Y = event.getY();
    System.out.println("ENDX---"+endx);
    System.out.println("endy-----"+endy);
    if(translation)
    translatedrawing(endx - startx,endy - starty);
    if(fence_zoom){
    System.out.println("mouse released");
    file://end1X = event.getX();
    // end1Y = event.getY();
    fzoom=true;
    repaint(); file://updateSize(event);
    else{
    fzoom=false;
    public void mouseDragged(MouseEvent event) {
    if(fence_zoom){
    end1X = event.getX();
    end1Y = event.getY();
    fzoom1=true;
    System.out.println("mouse dragged");
    repaint();
    else {
    fzoom1=false;
    public void mouseMoved(MouseEvent event)
    thanks
    sangeeta
    "Gustavo Henrique Soares de Oliveira Lyrio" wrote:
    I think you are using the wrong drawimage method. If you have the selection retangle coordinates, you will need a method that draw this selection in a new retangle selection (your canvas or panel)
    Where goes my paintMethod:
    protected void paintComponent(Graphics g)
    g.drawImage(image, START_WINDOW_X, START_WINDOW_Y, WINDOW_X, WINDOW_Y, px1, py1, px2, py2, this);
    Take a look in the drawimage methods in the java web page. I think it will help.
    []`s
    Gustavo
    ----- Original Message -----
    From: sangeetagarg
    To: Gustavo Henrique Soares de Oliveira Lyrio
    Sent: Thursday, August 16, 2001 9:14 AM
    Subject: Re: Re: re:zoom in 2d
    i'm sending u the paint method.but still i'm not able to select the desired area .it zooms the while image.tell me if there is any error in the code.
    file://if(fence_zoom)
    if(fzoom1 )
    if (currentRect != null) {
    System.out.println("hello");
    g.setColor(Color.white);
    g.drawRect(rectToDraw.x, rectToDraw.y,
    rectToDraw.width - 1, rectToDraw.height - 1);
    System.out.println("drawing rectangle");
    fzoom1=false;
    if(fzoom)
    bi = bimg.getSubimage(rectToDraw.x, rectToDraw.y, rectToDraw.width, rectToDraw.height);
    System.out.println(rectToDraw.x+","+ rectToDraw.y+","+rectToDraw.width+","+ rectToDraw.height);
    Graphics2D g2d = bi.createGraphics();
    g2d.setBackground(getBackground());
    g2d.clearRect(0, 0,0,0 );
    file://ZoomIn();
    file://t= g2d.getTransform();
    file://g2d.setTransform(t);
    System.out.println("settransform callrd");
    // zoomFactor *=1;
    g2d.translate(100.0f, 0.0f);
    g2d.scale(zoomx, zoomy);
    System.out.println("scale called"+zoomFactor);
    zoomx += ZOOMSTEP;
    zoomy += ZOOMSTEP;
    file://zoomFactor+=zoomFactorupdate;
    g.drawImage(bi, 0, 0, this);
    // g.drawImage(bi,10,10,this);
    repaint();
    fzoom=false;
    thanks
    sangeeta

  • How to get the width and height of the selected rectangle

    Hi,
         I need to get the width and height of the selected rectangle in indesign cs3 and display the values in a dialog box for user verification.
    Regards,
    saran

    Hi Saran,
    InterfacePtr<IGeometry> itemGeo ( objectUIDRef, UseDefaultIID() );
    PMRect ItemCoord = itemGeo->GetStrokeBoundingBox();
    PMReal width  = ItemCoord->Width();
    PMReal height = ItemCoord->Height();

  • Filtering images from the selection

    I am writing a script that involves scaling and sorting images. Which means i have to access the geometricBounds property of the images. Now, when the selection contains either an EPS or PDF file the script fails.
    So i am trying to filter through the selection array to find images that are NOT EPS or PDF. I noticed that EPS and PDF files don't have geometricBounds. So i was trying to use that property to sort it. But i am running into issues. Any thoughts? Solutions?
    if(app.documents.length != 0){
      if(app.selection.length != 0){
      for(myCounter = 0; myCounter < app.selection.length; myCounter++){
      switch(app.selection[myCounter].constructor.name)
      case "GraphicLine":
      case "Oval":
      case "Polygon":
      case "Rectangle":
      if(app.selection[myCounter].contentType != ContentType.UNASSIGNED){ // checks to make sure frame contains an image.
         if(app.selection[myCounter].graphics[0].geometricBounds[0]) { // checks to see if image has a width property. else it avoids it.
               myObjectList.push(app.selection[myCounter]);
      break;
      if(myObjectList.length !=0){
                        openDialog(myObjectList, keyObj);
      // moveItems(myObjectList);
      } else {alert("Select some images, fool!")}

    I noticed that EPS and PDF files don't have geometricBounds.
    Hi,
    Both do - check Object Model.
    Looks like there is another reason as your script fails. Cant say more without details.
    Notice that PDF and EPS is a standalone class (alike Image is) ==> so one does not include another.
    Jarek

  • Show only images in the selected folder

    Hi All,
    It would be nice if I could show only the images in the selected folder without including images in subfolders. For example a check box next to the folder name could switch between "selected folder only" and "include subfolders" viewing modes.

    Un-check Menu/Library/Include Photos from Subitems.
    It is already there in V1.1.
    Don
    Don Ricklin, MacBook 1.83Ghz Duo 2 Core running 10.4.10 & Win XP, Pentax *ist D
    http://donricklin.blogspot.com/

  • How to get UID of the selected PageItem

    Hi All,
    I have placed a image in a document . I select the image ,now i need the UID for the selected pagitem( i,e image).How to get it?
    Thanks
    Sakthi

    Hi,
    I think you have to check Selection Architecture.
    Thanks

  • How to get UIDRef of the selected page item in indesign cs3

    Hi,
        I want to get the UIDRef of the selected page item like Rectangle Frame. Can you show me the complete code snippet to get the UIDRef of selected Rectangle Frame. I need this UIDRef for getting the geometric bounds properties(width and height) of the selected rectangle frame to display the user in dialog box.
    Regards,
    K.Saravanan.

    Hi,
    UIDList selection;
    InterfacePtr<ISelectionManager> pSelectionManager(Utils<ISelectionUtils>()->GetActiveSelection(), ISelectionManager::kDefaultIID);
    if(pSelectionManager == nil){
    break;
    InterfacePtr<ILayoutTarget> pLayoutTarget(pSelectionManager->QueryConcreteSelectionBoss(kNewLayoutSelectionBoss), ILayoutTarget::kDefaultIID);
    if(pLayoutTarget == nil){
    break;
    selection = pLayoutTarget->GetUIDList(kDontStripStandoffs);
    Then, you can use this interface "IGeometry" to get information about spline size.
    InterfacePtr<IGeometry> pGeometry(selection.GetRef(i), IGeometry::kDefaultIID);
    if(pGeometry== nil){
    break;
    PMRect splineBounds = pGeometry->GetStrokeBoundingBox();
    PMReal width = splineBounds.Height();
    PMReal hight = splineBounds.Width();
    Regards,

  • When browsing a new library that I created, the browser shows dotted lines around grey rectangles, no images. When I double click on a rectangle the image appears. How do I get images to appear in the browser rectangles?

    When browsing a new library that I created and exported onto an external hard drive, the browser shows dotted lines around grey rectangles, no images. When I double click on a rectangle, the image appears, but all the other rectangles remain empty - no image. How do I get images to appear in the browser rectangles? I am viewing this on a second computer (an older intel duo iMac), not the one I created the library on (a MacBook Pro). Both computers have Aperture 3.2.4 installed. When I return the external to the MacBook, all images appear in browser rectangles. What's happening on the iMac?

    You may have a problem with the permissions on your external volume. Probably you are not the owner of your library on the second mac.
    If you have not already done so, set the "Ignore Ownership on this Volume" flag on your external volume. To do this, select the volume in the Finder and use the Finder command "File > Get Info" (or ⌘I).
    In the "Get Info" panel disclose the "Sharing & Permissions" brick, open the padlock, and enable the "Ignore Ownership on this Volume" flag. You will have to authentificate as administrator to do this.
    Then run the "Aperture Library First Aid Tools" on this library and repair the permissions. To launch the "First Aid Tools" hold down the ⌥⌘-key combination while you double click your Aperture Library. Select "Repair Permissions" and run the repair; then repeat with "Repair Database". Do this on the omputer where you created the library and where you can see the thumbnails.
    Then check, if you now are able to read the library properly on your iMac.
    Regards
    Léonie

  • How can I detect the vertices of a rectangle in my image ?

    I have applied a gradientMagnitude operator to my Image, and now I can see the shape of a rectangle with also other lines.
    How can I detect the vertices of the rectangle in my image?
    thank you

    Right mouse click the song and select "Get Info", go to option tab and check both Start Time and Stop Time.  Type in the Start and Stop time then click OK

  • I have 4 equal oblong shape created with borders How do I go about knowing what size the selection area is so that I can crop an image to fit. I don't want to use paste in then adjust the bounding box to suit

    I have 4 equal oblong shape created with borders How do I go about knowing what size the selection area is so that I can crop an image to fit. I don't want to use paste in then adjust the bounding box to suit

    What do you mean a moderator

  • In Indesign cc the preview of the selected image is not showing in the place dialog box how to enable that?

    I can't able to see the preview of the selected image in place dialog box of indesign cc but it working in indesign cs6

    Post Author: Argan
    CA Forum: .NET
    A couple things can cause this.
    Right click on the red x to find out the name of the png file.  Search the web server for that png and make sure that the asp worker has access to it.
    The other is a image handler issue.  Search the kbase for Red X NET 2005 and you will find a kbase or two that addresses this.

  • Copying and pasting adjustments.  When I copy the adjustments of an image, I thought I could then select several images and batch paste the adjustments to all selected images. But instead it's only pasting to the first photo of the selection. What am I do

    Copying and pasting adjustments.  When I copy the adjustments of an image, I thought I could then select several images and batch paste the adjustments to all selected images. But instead it's only pasting to the first photo of the selected. What am I doing wrong?

    Copy and Paste develop settings in Develop mode on multiple photos on the film strip works for me, even with Auto-Sync turned off.  Lr5.6 OSx 10.8.5

  • How to get the area of a selected rectangle?

    Hi:
    I want to use the selected area in a automation plugin. In my case, the area is rectangle. i can't get the top,left,bottom and right position.
    Is there anyone can help me?

    I'm petty you sure can extract the details you want using a script. I think the method is called Selection Bounds, and it return an array of the unitValue of the rectangle.
    If you look at the scriptlistener code for creating a rectangle, it does record the data you want. So you should be able to extract it using Javascript, Apple Script or VB
    This is what the scriptlistener code looks like,
    // =======================================================
    var id5 = charIDToTypeID( "setd" );
    var desc3 = new ActionDescriptor();
    var id6 = charIDToTypeID( "null" );
    var ref1 = new ActionReference();
    var id7 = charIDToTypeID( "Chnl" );
    var id8 = charIDToTypeID( "fsel" );
    ref1.putProperty( id7, id8 );
    desc3.putReference( id6, ref1 );
    var id9 = charIDToTypeID( "T " );
    var desc4 = new ActionDescriptor();
    var id10 = charIDToTypeID( "Top " );
    var id11 = charIDToTypeID( "#Pxl" );
    desc4.putUnitDouble( id10, id11, 210.000000 );
    var id12 = charIDToTypeID( "Left" );
    var id13 = charIDToTypeID( "#Pxl" );
    desc4.putUnitDouble( id12, id13, 276.000000 );
    var id14 = charIDToTypeID( "Btom" );
    var id15 = charIDToTypeID( "#Pxl" );
    desc4.putUnitDouble( id14, id15, 455.000000 );
    var id16 = charIDToTypeID( "Rght" );
    var id17 = charIDToTypeID( "#Pxl" );
    desc4.putUnitDouble( id16, id17, 613.000000 );
    var id18 = charIDToTypeID( "Rctn" );
    desc3.putObject( id9, id18, desc4 );
    executeAction( id5, desc3, DialogModes.NO );

  • How to Zoom the Image in JAI

    Hi,
    I need to zoom the image during the each button click.I have done 1 program ,but i coulnt able to change the parameter block's value each time.Take this program and just change the pic's path and run
    it ll show the pic,smaller than its actual size,because i changed the parameter block's value.this cahnge i want to do for each button click,please try to solve my problem,
    the code is
    import javax.swing.JFrame;
    import java.awt.Toolkit;
    import java.awt.Dimension;
    import java.awt.image.RenderedImage;
    import java.awt.image.BufferedImage;
    import java.awt.BasicStroke;
    import java.awt.Color;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseEvent;
    import javax.swing.JPanel;
    import java.awt.image.renderable.ParameterBlock;
    import java.io.IOException;
    import javax.media.jai.Interpolation;
    import javax.media.jai.JAI;
    import javax.media.jai.*;
    import java.awt.geom.*;
    import java.awt.geom.AffineTransform;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import javax.media.jai.RenderedOp;
    import com.sun.media.jai.codec.FileSeekableStream;
    import javax.media.jai.widget.ScrollingImagePanel;
    * This program decodes an image file of any JAI supported
    * formats, such as GIF, JPEG, TIFF, BMP, PNM, PNG, into a
    * RenderedImage, scales the image by 2X with bilinear
    * interpolation, and then displays the result of the scale
    * operation.
    public class JAISampleProgram extends DisplayJAI implements MouseListener
    JPanel jp=null;
    ParameterBlock params=null;
    Interpolation interp=null;
    RenderedImage image1;
    RenderedImage image2;
    RenderedImage rop;
    ScrollingImagePanel panel=null;
    JFrame jf=null;
    BufferedImage buff;
    Graphics2D graph;
    int width;
    int height;
    JAISampleProgram()
    JButton zoomin= new JButton(ico1);
    JButton zoomout = new JButton(ico2);
    jp = new JPanel();
    FileSeekableStream stream = null;
    try
    stream = new FileSeekableStream("D:/muthu/My Pictures/anniyan1.jpg");
    catch (IOException e)
    e.printStackTrace();
    System.exit(0);
    /* Create an operator to decode the image file. */
    image1 = JAI.create("stream", stream,null);
    * Create a standard bilinear interpolation object to be
    * used with the "scale" operator.
    interp = Interpolation.getInstance(
    Interpolation.INTERP_BICUBIC_2);
    * Stores the required input source and parameters in a
    * ParameterBlock to be sent to the operation registry,
    * and eventually to the "scale" operator.
    params = new ParameterBlock();
    params.addSource(image1);
    params.add(0.1f); // x scale factor
    params.add(0.1f); // y scale factor
    params.add(0.0F); // x translate
    params.add(0.0F); // y translate
    params.add(interp); // interpolation method
    /* Create an operator to scale image1. */
    image2 = JAI.create("scale", params,null);
    /* Get the width and height of image2. */
    width = image1.getWidth();
    height = image1.getHeight();
    /* Attach image2 to a scrolling panel to be displayed. */
    panel= new ScrollingImagePanel(image2, width, height);
    panel.setSize(400,300);
    setPreferredSize(new Dimension(image1.getWidth(),image1.getHeight()));
    buff = new BufferedImage(image1.getWidth(),image1.getHeight(), BufferedImage.TYPE_INT_RGB);
    width=image1.getWidth();
    height=image1.getHeight();
    graph = buff.createGraphics();
    graph.setStroke(new BasicStroke(2.0f));
    panel.addMouseListener(this);
    jp.add(zoomin);
    jp.add(zoomout);
    jf = new JFrame("sample");
    jf.setContentPane(panel);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    repaint();
    public void mouseClicked(MouseEvent e)
    ParameterBlock pb = new ParameterBlock();
    interp = Interpolation.getInstance(Interpolation.INTERP_BICUBIC_2);
    pb = new ParameterBlock();
    pb.addSource(image2);
    pb.add(0.5f); // x scale factor
    pb.add(0.5f); // y scale factor
    pb.add(0.0F); // x translate
    pb.add(0.0F); // y translate
    pb.add(interp); // interpolation method
    rop = JAI.create("scale", params,null);
    panel= new ScrollingImagePanel(rop, width, height);
    panel.setSize(400,300);
    setPreferredSize(new Dimension(image1.getWidth(),image1.getHeight()));
    buff = new BufferedImage(image1.getWidth(),image1.getHeight(), BufferedImage.TYPE_INT_RGB);
    width=image1.getWidth();
    height=image1.getHeight();
    graph = buff.createGraphics();
    graph.setStroke(new BasicStroke(2.0f));
    repaint();
    public void mouseEntered(MouseEvent e)
    public void mouseExited(MouseEvent e){}
    public void mousePressed(MouseEvent e){}
    public void mouseReleased(MouseEvent e){}
    public synchronized void paintComponent(Graphics g)
    panel.paintComponents(g);
    Graphics2D g2d = (Graphics2D)g;
    g = jp.getGraphics();
    g2d.setColor(Color.BLUE);
    g2d.drawLine(50,50,100,100);
    graph.setColor(Color.yellow);
    g.drawLine(60,60,120,120);
    g2d.drawRenderedImage(rop,AffineTransform.getTranslateInstance(100.00,100.00));
    /* params = params.set(0.1f,0);
    params = params.set(0.1f,1); */
    public static void main(String[] args)
    /* Validate input.
    * Create an input stream from the specified file name
    * to be used with the file decoding operator.
    JAISampleProgram jai = new JAISampleProgram();
    /* Create a frame to contain the panel. */
    jai.jf.pack();
    Toolkit theKit=Toolkit.getDefaultToolkit();
    Dimension dim=theKit.getScreenSize();
    int scrWidth=dim.width;
    int scrHeight=dim.height;
    jai.jf.setSize(scrWidth,scrHeight);
    jai.jf.show();
    }

    scale your Graphics2D object
    http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Graphics2D.html#scale(double,%20double)
    Also check the documentation of
    http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JComponent.html#paint(java.awt.Graphics)
    and see if your code would be better in paint(java.awt.Graphics) instead of paintComponent(Graphics g)

  • The selected original image is either offline or not found. Please reconnect it and try again.

    Hi to all, This is my first time here. I am having a problem that I've never had before. I am attempting to upload images to Flickr, which I do daily without trouble. However, this time I'm getting the message: "The selected original image is either offline or not found. Please reconnect it and try again." I am doing searches on my MacBook by copying and pasting the jpeg name in to the finder and they seem to be gone. I have taken special care to file my photos in certain folders. Either I have inadvertanly deleted entire folders or something very odd has happened. Can anyone shed any light on this? Thank you

    Hi, Thank you for the response.
    I'm on 10.7.5 OS
    Ver. 3.4.3 Aperture
    I have a folder on my desktop named "photo imports" I insert my card to the reader on my MacBook Pro and copy the files in to a folder nested within the Photo imports according to which camera I am using or sometimes it is a special project. This folder is on my computer's hard drive. 
    I then go in to Aperture and click "Import" I select in the "Store Files" menu: "in their current location"
    This has been working nicely for me. I use Time Machine on a somewhat regular basis and I also use other editing software like Picassa and View NX2 (Nikon software)
    I suppose that it is possible that I accidently dragged my folder in to the trash, but I really do try to be careful about that sort of thing. I have gone back in to Time Machine and have been unable to find the files. It is vexing. My granddaughter has been asking me for those particular pictures and the only way to view them is in Aperture on my computer because I am unable to email or export them in any way.

Maybe you are looking for