Want textarea to be displayed on the image

Hello,
I am stuck up with a problem,
I have a JPaaplet which displays an image,
and i want a textarea to appear whereever i click on the image.
and i dono how to get this.
it would be kindful if anyone could help me out with this. It is very urgent n i need to do it today itself
Regards
Sanam

Hello,
once again thanks for ur reply,
ur code works fine but when i try to implement it in mine it is not working, is it becoz u have used label
n i am using buffered image.
iam really stuck up with this. plzzzzzzzzzzzz help . this is the code i have written there is 1 main class (zoominApplet1) it has the main mtd .
1 more class(AppletZoomPanel) which basically performs zoomin n zoom out operation,
1 more calss(ZoomAction) which has buutons n operations performed on them.
now when i click on Auto Fit button i want the image to be resized to screen size.
could u plz tell what is the mistake n how to do it.
n i did not understand the 1st line of ur previous mail.
actually i am new this forum so i dono abt those duke dollars
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.util.Vector;     
//ZoominApplet1 class
public class ZoominApplet1 extends JApplet
     public static JFrame f;
     public AppletZoomPanel zoomPanel;
     public static Container cp;
     public BufferedImage image;
     JTextArea textArea;
     public void init()
          zoomPanel = new AppletZoomPanel();
          ZoomAction action = new ZoomAction(zoomPanel);
          cp = getContentPane();
          cp.setLayout(new BorderLayout());
          //cp.setLayout(null);
          cp.add(action, "North");
          cp.add(new JScrollPane(zoomPanel));
          txtArea();
     public void txtArea()
          zoomPanel.addMouseListener(new MouseAdapter()
               public void mousePressed(MouseEvent e)
                    textArea = new JTextArea();
                    textArea.setBorder(BorderFactory.createLineBorder(Color.BLACK));
                    zoomPanel.add(textArea);
                    textArea.setBounds(e.getX(), e.getY(), 100,50);
          SwingUtilities.invokeLater(new Runnable()
               public void run()
                    f.pack();
                    f.show();
     public static void main(String[] args)
          JApplet applet = new ZoominApplet1();
          f = new JFrame();
          f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          f.getContentPane().add(applet);
          f.setSize(300,300);
          //f.setLocation(100,100);
          applet.init();
          f.setVisible(true);
//AppletZoompanel class
class AppletZoomPanel extends JPanel
     public BufferedImage image;
          double scale, scaleInc;
     public boolean autofit = false;
     public AppletZoomPanel()
          loadImage();
          scale = 1.0;
          scaleInc = 0.01;
          setBackground(Color.white);
          //Set to null
          setLayout(null);
     protected void paintComponent(Graphics g)
          super.paintComponent(g);
          Graphics2D g2 = (Graphics2D)g;
          g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                    RenderingHints.VALUE_INTERPOLATION_BICUBIC);
          int w = getWidth();
          int h = getHeight();
          System.out.println("width : " +w);
          System.out.println("height : " +h);
          double imageWidth = scale * image.getWidth();
          double imageHeight = scale * image.getHeight();
          double x = (w - imageWidth)/2;
          double y = (h - imageHeight)/2;
          AffineTransform xform = AffineTransform.getTranslateInstance(x, y);
          xform.scale(scale, scale);
          g2.drawRenderedImage(image, xform);
     public Dimension getPreferredSize()
          Dimension d = new Dimension();
          d.width = (int)(scale * image.getWidth());
          d.height = (int)(scale * image.getHeight());
          return d;
     public void autoFit()
     public void setScale (int inc)
          scale += inc * scaleInc;
          revalidate();
          repaint();
     private void loadImage()
          String fileName = "sampleimg.jpg";
          try
          URL url = getClass().getResource(fileName);
          image = ImageIO.read(url);
          catch(MalformedURLException mue)
          System.out.println("url: " + mue.getMessage());
          catch(IOException ioe)
          System.out.println("read: " + ioe.getMessage());
//ZoomAction Class
class ZoomAction extends JPanel
     static final String[] fontStyleString = new String[] {"Font.PLAIN", "Font.ITALIC", "Font.BOLD", "Font.ITALIC+Font.BOLD"};
     static final int[] fontStyleInt = new int[] { Font.PLAIN ,  Font.ITALIC ,  Font.BOLD ,  Font.ITALIC+Font.BOLD };
     AppletZoomPanel zoomPanel;
     public ZoomAction(AppletZoomPanel azp)
          zoomPanel = azp;
          final JButton zoomIn = new JButton("zoom in"), zoomOut = new JButton("zoom out"), autoFit = new JButton("Auto Fit"), txtButton = new JButton("Text Area");
          JComboBox fontCombo;
          JComboBox styleCombo;
          String[] fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
          //final JButton autoFit = new JButton("Auto Fit");
          /*add(new JButton(new AbstractAction("Auto Fit")
               public void actionPerformed(ActionEvent e)
                    System.out.println("autofit");
                    zoomPanel.setBounds(new Rectangle(zoomPanel.getSize()));
                    repaint();
//                    ResizableImage resizableImage = new ResizableImage();
                    //resizeableImage.autoFit();
                    //resizableImage.setBounds(new Rectangle(zoomPanel.getSize()));
//                    resizableImage.setBounds(new Rectangle(resizableImage.getPreferredSize()));
//                    resizableImage.repaint();
     //               repaint();
          Vector visFonts = new Vector(fontNames.length);
          for(int i=0; i<fontNames.length; i++)
               Font f = new Font(fontNames, Font.PLAIN, 12);
               if (f.canDisplay('a'))
                    visFonts.add(fontNames[i]);
               else
                    //System.out.println("No alphabetics in " + fontNames[i]);
          fontCombo = new JComboBox(visFonts);
          styleCombo = new JComboBox(fontStyleString);
          ActionListener l = new ActionListener()
               int inc;
               public void actionPerformed(ActionEvent e)
                    JButton button = (JButton)e.getSource();
                    if(button == zoomIn)
                    inc = 5;
                    if(button == zoomOut)
                    inc = -5;
                    zoomPanel.setScale(inc);
          zoomIn.addActionListener(l);
          zoomOut.addActionListener(l);
          ActionListener m = new ActionListener()
               public void actionPerformed(ActionEvent e)
                    JButton button = (JButton)e.getSource();
                    if(button == autoFit)
                         System.out.println("autofit");
                         //zoomPanel.setBounds(new Rectangle(zoomPanel.getSize()));
                         //repaint();
                         ResizableImage     resizableImage = new ResizableImage();
                         resizableImage.repaint();
                         System.out.println("repaint");
                         //zoomPanel.setBounds(new Rectangle(zoomPanel.getSize()));
     //                    final AppletZoomPanel resizableImage = new ResizableImage(new                               ImageIcon(imageUrl).getImage());
                    if(button == txtButton)
                              //AppletZoomPanel azp1 = new AppletZoomPanel();
                              //azp1.setTextArea();
                              //ZoominApplet1 za1 = new ZoominApplet1();
                         //za1.txtArea();
          autoFit.addActionListener(m);
          txtButton.addActionListener(m);
          add(txtButton);
          add(zoomIn);
          add(zoomOut);
          add(autoFit);
          add(fontCombo);
          add(styleCombo);
     public Dimension getPreferredSize()
          return new Dimension(ap.image.getWidth(null), ap.image.getHeight(null));
     AppletZoomPanel ap = new AppletZoomPanel();
     protected void paintComponent(Graphics g)
          Graphics2D g2D = (Graphics2D)g;
          System.out.println("grahics :" +g2D);
          Dimension dim = getSize();
          System.out.println("dim : " +dim);
          int imageWidth = ap.image.getWidth(null);
          System.out.println("width : " +imageWidth);
          int imageHeight = ap.image.getHeight(null);
          System.out.println("height : " +imageHeight);
          double scaleX = (double)dim.width / (double)imageWidth;
          System.out.println("scalex : " +scaleX);
          double scaleY = (double)dim.height / (double)imageHeight;
          System.out.println("scaley : " +scaleY);
          g2D.drawImage(ap.image, AffineTransform.getScaleInstance(scaleX, scaleY), null);
class ResizableImage extends JComponent
     AppletZoomPanel ap = new AppletZoomPanel();
     public Dimension getPreferredSize()
          return new Dimension(ap.image.getWidth(null), ap.image.getHeight(null));
     public void paintComponent(Graphics g)
          super.paintComponent(g);
          Graphics2D g2D = (Graphics2D)g;
          System.out.println("grahics :" +g2D);
          Dimension dim = getSize();
          System.out.println("dim : " +dim);
          int imageWidth = ap.image.getWidth(null);
          System.out.println("width : " +imageWidth);
          int imageHeight = ap.image.getHeight(null);
          System.out.println("height : " +imageHeight);
          double scaleX = (double)dim.width / (double)imageWidth;
          System.out.println("scalex : " +scaleX);
          double scaleY = (double)dim.height / (double)imageHeight;
          System.out.println("scaley : " +scaleY);
          g2D.drawImage(ap.image, AffineTransform.getScaleInstance(scaleX, scaleY), null);

Similar Messages

  • How do i set up a second display for my iMac desktop?  I want to use both displays at the same time.

    how do i set up a second display for my iMac desktop?  I want to use both displays at the same time.  My iMac is the 24" Late 2006 model.  I recall that there is a cord for plugging in a second monitor, but I want to make sure that i can use both monitors side-by-side at the same time.  thank you.

    If the Display supports DVI, then you will need a > Mini-DVI to DVI Adapter and a DVI cable.
    If the Display only supports VGA, then you wiil need a > Mini DVI to VGA Adapter and a VGA cable.
    Noting that the (digital) DVI is far better than the (analog) VGA connection.
    Also see > Using Dual Displays on Mac OS X: The Experience

  • Is there a way to display all the image files(jpeg, png, �) present in the

    Description:
    Currently I am using �Sun Java� Wireless Toolkit 2.5 for CLDC, Beta 2 � toolkit for developing J2ME applications. I am using the �javax.microedition.amms.control.imageeffect� package(JSR 234) for adding effects like red eye, border, etc. I need to display all the images in my /res folder so that the user can select one from the list for further image processing. I used File Connection API for displaying the images from the file system's /root folder. But while trying to apply the image effects I found that I can not access the file system's /root folder through getResourceAsStream(). getResourceAsStream()could only access the /res folder . Is this correct? Is there any other way to give the InputStream to the media processor through setInput()? Is there any other alternative to getResourceAsStream()? Or Is there any direct way to access the /res folder and display all its files for the user to select?
    Here is the code that I am using for providing the input and output streams and applying the image effect to the source file �Duke.jpg� in /res folder.
    MediaProcessor mp = GlobalManager.createMediaProcessor("image/jpeg");
    mp.addMediaProcessorListener(this);
    outputStream = new ByteArrayOutputStream();
    inputStream= getClass().getResourceAsStream(�Duke.jpg�);
    mp.setInput(inputStream, MediaProcessor.UNKNOWN);
    mp.setOutput(outputStream);
    ImageTransformControl itc = ImageTransformControl) mp.getControl ("javax.microedition.amms.control.imageeffect.ImageTransformControl");
    final int border =10;
    itc.setSourceRect(itc.getSourceWidth(), 0, -itc.getSourceWidth() , itc.getSourceHeight() );
    itc.setTargetSize(itc.getSourceWidth(),itc.getSourceHeight(),0);
    itc.setEnabled(true);
    mp.start();
    mp.complete();

    you need to set resource path correct place image file resource folder is correct but there is problem so yu need put the image in resource in this way C:\WTK23\apps\Image\res\example\hello\image.gif this work
    in the code try this InputStream byteInput = getClass().getResourceAsStream("/example/hello/image.gif"); this works if you need any more help contant [email protected]

  • Dyanmic display of the Image Link URL

    I have a typical report requirement for which I have googled but didnot get the proper solution.
    The report contains two columns , OrderId (Datatype Integer) and CustomerName .
    OrderId CustomerName
    123     xyz
    234     abc
    345     pqr
    456     klm
    The requirement is whenever the user clicks on the OrderId it should display its corresponding Invoice image.
    The URL is
    http://server/ibpmweb/login/soaplogin.asp?SearchName=OrderId&param=ORDERID&ID=XXXXXX
    where XXXXXX -----> OrderID
    The OrderID should change dynamically in the URL and should display the corresponding Invoice Image for the OrderID.
    Please suggest me workaround to achieve this problem.
    Your quick reponse is highly appeciated.
    Thanks,
    Rama

    Since you want to display the Order ID and have a hyperlink on it, you could use the following as the formula for the Order ID column.
    '<a href= http://server/ibpmweb/login/soaplogin.asp?SearchName=OrderId&param=ORDERID&ID=' || cast(order.order_ID as char(5))||' target="_blank" '||'>'|| order.order_ID||'</a>'
    Replace Order. Order_ID with your table and column name. The '_blank' is for the hyperlink to open in new page. Also, note that in the line above, the two single quotes in the end( ' ') should be replaced with single quote, less than sign, forward slash, the alphabet a, and the greater than sign, and single quote. The last part does not display in the forum.
    Also, replace char(5) with the appropriate precision as required.
    Hope this helps!

  • Firefox is not displaying all the images on any of the websites that I access. I upgraded to 4.0 and it worked correctly for about a day and then reverted back to the problem.

    When I open a website using Firefox it displays the text but none of the graphics. I upgarded to 4.0 and it was temporarily corrected. Now it has reverted to no graphics,

    Hi there,
    I have the same issue: FireFox is not showing all images on the page.
    Noticed this in FireFox 5.0. Now I installed FireFox 5.0.1 and still have the same issue.
    The missing images do not even appear in Tools > Page Info > Media.
    The images are usually accessed using DIV tag with a CSS class which contains background-image style. Often, when page opens, the DIV is initially hidden, and JavaScript displays it. Sometimes, jQuery.html() adds such DIV tags, and images rarely appear. Sometimes they do, but more often they do not.
    If I install FireBug and use Inspect Element to find such a DIV, it is there, it contains the CSS class, the definition of the CSS class contains background-image style. If I click the icon to disable this style, and then click it again to enable it, the image immediately shows up.
    Seems to be caused by some optimization which does not detect images like these.
    Hope this helps you reproduce it.

  • Table of content, I want to display just the image for each chapter and the name of the chapter. my book is not landscape format but each time I draging a picture into a specific chapter it duplicate it to all chapters why?

    table of content in a landscape orientation.
    I want to have in my table of content only image and the name of the chapter which is each to do.
    my problem when I am draging an image to each chapter it copied it to all chapter although I am marking only the specifc chapter.
    why? how can i overcome it?

    Are you using Microsoft word?  Microsoft thinks the users are idiots. They put up a lot of pointless messages that annoy & worry users.  I have seen this message from Microsoft word.  It's annoying.
    As BDaqua points out...
    When you copy information via edit > copy,  command + c, edit > cut, or command +x, you place the information on the clipboard. When you paste information, edit > paste or command + v, you copy information from the clipboard to your data file.
    If you edit > cut or command + x and you do not paste the information and you quite Word, you could be loosing information.  Microsoft is very worried about this. When you quite Word, Microsoft checks if there is information on the clipboard & if so, Microsoft puts out this message.
    You should be saving your work more than once a day. I'd save every 5 minutes.  command + s does a save.
    Robert

  • Eliminate the border  displayed around the image in a command hyperlink

    How can i please eliminate the border displayed around image in a command hyperlink component.
    Thanks.

    That's just a layout issue. Apply CSS accordingly.

  • Display of the images became very large in macbook air, display of the images became very large in macbook air

    suddenly the display became very large. it seems like the dsiplay for  the handicap as if in ipad. How to restore to normal display? Thank

    This link may help http://docs.info.apple.com/article.html?path=Mac/10.7/en/mchlp2368.html

  • I want to change my display name,,,the instruction...

    Help....instructions for changing display name are confusing....help!

    Hello,
    If you let me have the display name you wish to use (by PM) I will change it for you.
    TIME ZONE - US EASTERN. LOCATION - PHILADELPHIA, PA, USA.
    I recommend that you always run the latest Skype version: Windows & Mac
    If my advice helped to fix your issue please mark it as a solution to help others.
    Please note that I generally don't respond to unsolicited Private Messages. Thank you.

  • Do not want JFrame to be displayed in the taskbar

    A quick one. How can you create a JFrame so it does not appear in the taskbar?
    Thanks.

    JWindow is a good possibility but again you dont get all the stuff that goes with JFrame. The other possibility is you could explore JNI, you should be able to find ways to make the JFrame not to show on the taskbar.

  • Why does moving the mouse over an IMAQ image display slow the GUI down so much?

    I have a large application with several vi's running simultaneously under labview 8.6.1.  When I mouse over an image display control in one of the vi's, everything slows down a shocking amount in all the other vi's.  The windows task manager does not show a large increase in CPU use.  My pc is has a quad cpu with 4GB of RAM, and the CPU and memory loads do not appear to be terribly taxing to the system.  However, many of my vi's apparently come almost to a standstill if I just move the mouse in a circle around my image control.
    This looks like it is largely a GUI display issue.  If I make a new vi and put a while loop in it that only displays the iteration loop number to an indicator, I can see the iterating occurring, then stopping totally when I mouse inside the image display control.  When I stop moving the mouse inside the control, or when I move it outside the control, the interation loop number jumps up, as if it had been incrementing behind the scenes the whole time.  So only display of the interating was halted.
    This problem occurs even if the vi with the image control is not executing.  If the vi with the image control is open but not running, and I mouse over the image on it, the other guis all come to a screeching halt.
    Does mousing in the image display control really utterly crush all other guis in all other labview windows?  Is this an issue inherent to the image display control?  If so, is there anything I can do about this? 
    Also, this issue is not entirely limited to display.  I started looking at it in greater detail because this issue also exposed what I think is a race condition in my code.  I have a vi that acquires an image from a ccd and puts it into an IMAQ image.ctl.  This image then gets passed up to a vi up the call chain, and is put on a queue and sent over to be de-queued by a vi that has the image display control.  Here's the kicker:  when I mouse over the image display control, the image successfully gets acquired inside the subvi, and if I probe the wire leading to the output IMAQ image display.ctl, I see the image.  If I simultaneously probe the wire coming out of the subvi one level up the call chain, the image gets lost about half the time.  This only happens if I am mousing in the image display control IN A TOTALLY DIFFERENT AND SEPARATE VI.  If I bump up the priority of the ccd image acquisition vi to 'highest priority', the problem only happens about 1% of the time, and I really have to mouse around to make it happen.  Still, it's disturbing that mousing in the GUI in one window results in a failure of a separate subvi to simply pass an image up the call chain.  I understand that IMAQ images are referenced rather than passed by value, but I don't see why there should be a failure to pass the image up the call chain.  I've looked for a race condition, but can't find one.
    Eric

    I have finally been able to replicate the behavior that you are seeing on another computer once the image was large enough.  Here are a few notes about this behavior:
    First. The UI only slows down when the images are large, 16 bit images.  The reason why this is unique to 16 bit images is that they can only be displayed on the front panel as 8 bit images.  The workaround that Weiyuan suggested to change the 16 bit display mapping hints towards the root of the problem...that any time a mouse runs over the indicator, Windows asks the entire image to re-draw (having a separate indicator overlapping the image will create the same behavior).  With a 16 bit image, not only does the image have to re-draw on the screen but the 16 bit pixels need to be mapped to 8 bits.  When setting the 16 bit display mapping to Full Dynamic, this requires mor computation/pixel than 90% dynamic or one of the other mapping schemes.
    This is expected behavior if your program is running and you're trying to display a large 16 bit image.  To fix this behavior there are a couple options:
    Change the 16 bit display mapping to something other than full dynamic.  You can choose which 8 bits to display or if you want to map the bits. 
    Resize the image just for viewing purposes on your front panel (since you aren't going to view every single pixel of you image on the screen). You can use the IMAQ Resample.vi to do this.  This will allow you to take your 1500x1500 pixel image and only display a 500x500 pixel version.
    If you are interested in viewing small details of the large image, consider just displaying a smaller region of interest at a time.
    Let me know if any of these solutions work for you.  Good luck on your application.
    Zach C.
    Field Engineer
    Greater Los Angeles

  • I got the image on the vi,now I want to take rectangle potion from that image and compare with other image

    Hi,
    Now i have a image on VI ,i want to take rectangale postion of the image and compare with the other image(In this image also i need to take a small postionof it) and  show the result.
    Both image are equal or not....if it is equal show pass if the image is not ok fail.
    Regards,
    Sri.

    First i would like to thanks for the inputs,
    I have made one Vi for comparing the two images and display  equal or not.
    Problem:if there is a small change in the picture it is showing false ,but the image is ok only the contract ,clarity ,inclination is the problem... i need your help in controlling that image......like controlling the colors and telling if the color , shade, projection of the image of the image is in between this range show it as ok....
    i started with cluster taking the out put of the BMP file, but i am not able to do....can u help me on this.
    i am attaching the file what i have made...
    Regards,
    Sri
    Color
    Attachments:
    image.ppt ‏52 KB

  • ITunes does not display my feed image as defined in the itunes:image tag

    I set up a feed using a custom PHP script I wrote. This script creates an rss file that I will submit to apple once I have everything ironed out. right now the only thing left to fix is the missing feed image. I checked the xml and for the image I have:
    *<itunes:image href="http://www.roaringbrookbaptistchurch.org/podcasts/feed/images/feedIcon.jp g" />*
    I checked the image in a browser and it indeed exists and displays as expected, this is a test image not the final one. It is a 600x600 jpg. I am previewing my podcast in itunes using a direct link to this rss file.
    Why is my image not showing up? I get some other image, not sure where it comes from, instead.

    When you subscribe to a podcast feed, either from the Store or - as I assume you have done - from the 'Advanced' menu, the image referred to in that tag is not displayed. The images which are seen on selecting each episode have to be embedded in the actual media file: please see this page -
    http://homepage.mac.com/rfwilmut/notes/faq.html#coverart
    You will not see the image referenced in the feed until the podcast is actually accepted and shows in the Store.

  • How to display multi-channel image in the 'proxy'?

    There're many examples to show how to display composite channels in the 'proxy'. But I don't find any example to show how to display multi-channel image in the 'proxy'. I found that I can use PSPixelOverlay to display alpha channel data like this:
    int nSpotChannel = gChannelCount - 4;
    PSPixelOverlay* overlay = new PSPixelOverlay[nSpotChannel];
    for(int i = 0; i < nSpotChannel; i++){
           if( i != (nSpotChannel - 1) )
                 overlay[i].next = overlay + i + 1;
           else
           overlay[i].next = NULL;
           overlay[i].data = gChannelData + (4 + i) * nPlaneBytes;
           overlay[i].rowBytes = gProxyRect.Width() * gDocDesc->depth / 8;
           overlay[i].colBytes = 1;
           overlay[i].r  = 230;
           overlay[i].g = 161;
           overlay[i].b = 174;
           overlay[i].opacity = 255;
           overlay[i].overlayAlgorithm = kStandardAlphaOverlay;
    pixels.pixelOverlays = overlay;
    Then, Seeing red part, it will trigger a new problem, that is how to get the color value of the alpha channel by plung-in itself? It seems that no channel color value info is in FilterRecord.
    If you have other solution, please tell me. Many thanks!

    This is what I've been doing - was just curious if there was a way to see a more cohesive image.
    If the individual EQ plugins are in fact the answer, is there any way to smooth how the Analyzer displays? The image I posted above, all of the tonal curves are very smooth. The analyzer tool shows a lot of peaks and valleys within the overall curve and it's hard to pinpoint each instrument's "sweet spot." Vocals for example are very hard to spot.
    - Morgan

  • Centering Images using CSS but having links on the Images

    Hi all,
    I have a problem on centering an image using CSS. I read on many forums that you have to use margin-left , margin-right and set to auto. and also set the display:block which I had done.
    The problem is if I want to have a link from the image. Because I have set the display to block, the link will span the entire container containing it! How do I resolve that? I only want the image to be linkable and not the entire container!
    Thanks for reading!

    Murray *ACP* wrote:
    Because I have set the display to block, the link will span the entire container containing it!
    That's incorrect.  If the display:block is applied to only the IMAGE, the anchor tag will be exactly the same dimensions as the image and will not fill the container.
    Hi Murray,
    Weirdly it does in my experiments. (code below). Even if I set the 'a' tag to the width of the image it still makes the whole <div> container clickable:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    #imgWrapper {
        width: 900px;
        margin: 0 auto;
        border: 1px solid #000;
    #imgWrapper img {
        margin: 0 auto;
        display: block;
    </style>
    </head>
    <body>
    <div id="imgWrapper">
    <a href="http://www.bbc.co.uk"><img src="slice_2.jpg" width="595" height="130" /></a></div>
    </body>
    </html>

Maybe you are looking for