Clear image on canvas

How to clear the image on canvas? I have a big image span the whole screen and I want to put another smaller image now. There is no "clear" method to be called! What I can do is to draw a rectangle. Any suggestion?
Thanks!

The following should clear your screen.
  // Clear the whole screen.
  g.setColor(255, 255, 255);
  g.fillRect(0, 0, getWidth(), getHeight());

Similar Messages

  • Extracting transparent image from canvas

    Hi Folks,
    Given an image painted on a graphics2D, I need to copy some parts of this image to be able to process them and repaint them in place, giving to the original image a different look.
    Theses parts are not rectangles but donuts like shapes (circular surface with a hole in he middle).
    The approach I tried in the following:
    - Combining 2 ellipses Shape to be able to create an Area representing the donut shaped surface
    - Clipping the Graphics2D this Area
    [at this point, if the panel is repainted with the clip set, the original image is only visible through the donut shape clip, which is exactly was I want]
    - creating a new image with transparency, painting the clipped original image onto this new image
    [that's where it does not work, if I paint the new image on the canvas, it's blank, or when I disabled transparency, it's a squared shape, and not a donut like shape]
    Any help/hint would be gladly appreciated, below in the paintComponent method
    Thanks
    Elie
    public synchronized void paintComponent(Graphics g) {
            g2d = (Graphics2D)g;
            if ( readyToDisplayImage == null ) {
                g2d.setColor(getBackground());
                g2d.fillRect(0, 0, getWidth(), getHeight());
                return;
            // account for borders
            Insets insets = getInsets();
            int tx = insets.left + originX;
            int ty = insets.top  + originY;
            // clear damaged component area
            Rectangle clipBounds = g2d.getClipBounds();
            g2d.setColor(getBackground());
            g2d.fillRect(clipBounds.x,
                         clipBounds.y,
                         clipBounds.width,
                         clipBounds.height);
              g2d.drawRenderedImage(readyToDisplayImage,
                                  AffineTransform.getTranslateInstance(tx, ty));
       if(test) {
            Shape oldClip = g2d.getClip() ;
            Shape s1 = (new Circle(500,500, 150)).toEllipse2D();
            Shape s2 = (new Circle(500,500, 250)).toEllipse2D();
            Area a1 = new Area(s1);
            Area a2 = new Area(s2);
            a2.subtract(a1); // donut shaped mask
             g2d.setColor(getBackground());
             g2d.fillRect(0, 0, getWidth(), getHeight());
            g2d.setClip(a2) ;
            g2d.drawRenderedImage(readyToDisplayImage,AffineTransform.getTranslateInstance(tx, ty));
            Rectangle bounds = a2.getBounds();
            BufferedImage subimage = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D) subimage.createGraphics();
            // Clear image with transparent alpha by drawing a rectangle  - commented beacause worsens things
           // g2.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
           // Rectangle2D.Double rect = new Rectangle2D.Double(0,0,bounds.width, bounds.height);
            //g2.fill(rect);
            g2.drawRenderedImage(readyToDisplayImage, AffineTransform.getTranslateInstance(bounds.x, bounds.y));
            g2.dispose();
            g2d.setClip(oldClip) ; //back to normal
         // Now checking whether the extracted sub image has the expected shape : this is not the case
             g2d.setColor(getBackground());
             g2d.fillRect(0, 0, getWidth(), getHeight());
             g2d.drawImage(subimage, bounds.x, bounds.y, this );
        }

    I found another way, which is using ROIShape class as mask.
    But an exception is raised by the last line of the method.
    Apparently the resulting image form and "add" between a oneband and a 3 band image is not supported.
    Also, if I do convert the one band image to color, it does not solve the problem
    ColorModel colorModel = cropped.getColorModel();
    pb = new ParameterBlock();
         pb.addSource(maskimage);
         pb.add(colorModel);
    maskimage = JAI.create("colorconvert", pb);
    What would be the right way to do this ?
    Thanks
    trace:
    image mask bounds=java.awt.Rectangle[x=250,y=250,width=500,height=500]
    cropped image bounds=java.awt.Rectangle[x=250,y=250,width=500,height=500]
    subimage image bounds=java.awt.Rectangle[x=250,y=250,width=500,height=500]
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at com.sun.media.jai.opimage.AddOpImage.computeRectByte(AddOpImage.java:268)
    at com.sun.media.jai.opimage.AddOpImage.computeRect(AddOpImage.java:220)
    at javax.media.jai.PointOpImage.computeTile(PointOpImage.java:974)
    at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:912)
    at javax.media.jai.OpImage.getTile(OpImage.java:1139)
    at javax.media.jai.RenderedOp.getTile(RenderedOp.java:2268)
    at sun.java2d.SunGraphics2D.drawTranslatedRenderedImage(SunGraphics2D.java:2864)
    at sun.java2d.SunGraphics2D.drawRenderedImage(SunGraphics2D.java:2751)
    at circleops.ImagePanel.paintComponent(ImagePanel.java:253)
    public synchronized void paintComponent(Graphics g) {
            g2d = (Graphics2D)g;
            if ( readyToDisplayImage == null ) {
                g2d.setColor(getBackground());
                g2d.fillRect(0, 0, getWidth(), getHeight());
                return;
            // account for borders
            Insets insets = getInsets();
            int tx = insets.left + originX;
            int ty = insets.top  + originY;
            // clear damaged component area
            Rectangle clipBounds = g2d.getClipBounds();
            g2d.setColor(getBackground());
            g2d.fillRect(clipBounds.x,
                         clipBounds.y,
                         clipBounds.width,
                         clipBounds.height);
                Translation moves the entire image within the container
            g2d.drawRenderedImage(readyToDisplayImage,
                                  AffineTransform.getTranslateInstance(tx, ty));
            g2d.setColor(Color.red);                     
            g2d.fillRect(lastClickedX-4, lastClickedY-4, 8, 8);
            //System.out.println("x="+currentX+" y="+currentY);
            Iterator<ConcentricTurbulence> it = concentrics.iterator();
            while(it.hasNext()) {
            if(test) {
            Shape oldClip = g2d.getClip() ;
            Shape s1 = (new Circle(500,500, 150)).toEllipse2D();
            Shape s2 = (new Circle(500,500, 250)).toEllipse2D();
            Area a1 = new Area(s1);
            Area a2 = new Area(s2);
            a2.subtract(a1);
            ROIShape roishape = new ROIShape(a2);
            PlanarImage maskimage = roishape.getAsImage();
            Rectangle bounds = maskimage.getBounds();
            System.out.println("image mask bounds="+bounds.toString());
            ParameterBlock pbc = new ParameterBlock();
            pbc.addSource(readyToDisplayImage);
            pbc.add((float)bounds.x);
            pbc.add((float)bounds.y);
            pbc.add((float)bounds.width);
            pbc.add((float)bounds.height);
            PlanarImage  cropped = JAI.create("Crop", pbc, null);
            System.out.println("cropped image  bounds="+cropped.getBounds());
            ParameterBlock pbd = new ParameterBlock();
            pbd.addSource(cropped);
            pbd.addSource(maskimage);
            PlanarImage  subimage = JAI.create("add", pbd, null);
            System.out.println("subimage image  bounds="+subimage.getBounds());
             g2d.setColor(getBackground());
             g2d.fillRect(0, 0, getWidth(), getHeight());
             g2d.drawRenderedImage(subimage, AffineTransform.getTranslateInstance(bounds.x, bounds.y));
        }

  • Simple image on canvas help

    Hi, im 'developing' a small piece of software that allows the user to draw a single line on an image (basic shell of the program) but i have seemed to run into a spot of bother. Can anyoone please look at this piece of applet software and tell me where i am going wrong... I get an Applet notinited error message when i try to run it, anyones help will be much appreciated.
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import java.applet.Applet;
    public class LineDraw extends Applet
    SimpleDrawCanvas canvas;
    public void init() {
    canvas = new SimpleDrawCanvas();
    Panel bottom = new Panel();
    Button b1 = new Button("Clear");
    b1.addActionListener(canvas);
    bottom.add(b1);
    setBackground(Color.blue);
    setLayout(new BorderLayout(3,3));
    add("Center",canvas);
    add("South",bottom);
    public Insets getInsets()
    return new Insets(25,25,25,25);
    class Line
    int x1, y1;
    int x2, y2; }
    class SimpleDrawCanvas extends Canvas implements ActionListener, MouseListener
    Image img = Toolkit.getDefaultToolkit().getImage ( "ireland.gif" );
    Color currentColor = Color.red;
    SimpleDrawCanvas() {
    setBackground(Color.green);
    currentColor = Color.red;
    addMouseListener(this);
    void doClear()
    repaint();
    public void actionPerformed(ActionEvent evt) {
    String command = evt.getActionCommand();
    if (command.equals("Clear"))
         doClear();
    int startX, startY;
    public void mousePressed(MouseEvent evt) {
    startX = evt.getX();
    startY = evt.getY();
    public void mouseReleased(MouseEvent evt) {
    int endX = evt.getX();
    int endY = evt.getY();
    Graphics g = getGraphics();
    g.drawImage(img, 0, 0, 400, 400, this);
    g.setColor(currentColor);
    g.drawLine(startX, startY, endX, endY);
    g.dispose();
    public void mouseClicked(MouseEvent evt) { }
    public void mouseEntered(MouseEvent evt) { }
    public void mouseExited(MouseEvent evt) { }
    }

    Ok, after all this i have realised that i only need to set the picture as the background image, it will not be interacted with so i can put it in the HTML file like so...
    <html>
    <body>
    <applet code="LineDraw.class" width=400 height=594>
    <param name="image" value="ireland.gif">
    </applet>
    </body>
    </html>
    the rest of the code has slightly changed, it now looks like this...
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.net.*;
    import java.applet.*;
    import java.util.*;
    public class LineDraw extends Applet
    SimpleDrawCanvas canvas;
    public void init()
    canvas = new SimpleDrawCanvas();
    Panel bottom = new Panel();
    Button b1 = new Button("Clear");
    b1.addActionListener(canvas);
    bottom.add(b1);
    setBackground(Color.blue);
    setLayout(new BorderLayout(3,3));
    add("Center",canvas);
    add("South",bottom);
    public Insets getInsets()
    return new Insets(25,25,25,25);
    class Line
    int x1, y1;
    int x2, y2; }
    class SimpleDrawCanvas extends Canvas implements ActionListener, MouseListener
    Color currentColor = Color.red;
    SimpleDrawCanvas()
    setBackground(Color.green);
    currentColor = Color.red;
    addMouseListener(this);
    void doClear()
    repaint();
    public void actionPerformed(ActionEvent evt) {
    String command = evt.getActionCommand();
    if (command.equals("Clear"))
         doClear();
    int startX, startY;
    public void mousePressed(MouseEvent evt) {
    startX = evt.getX();
    startY = evt.getY();
    public void mouseReleased(MouseEvent evt) {
    int endX = evt.getX();
    int endY = evt.getY();
    Graphics g = getGraphics();
    g.setColor(currentColor);
    g.drawLine(startX, startY, endX, endY);
    g.dispose();
    public void mouseClicked(MouseEvent evt) { }
    public void mouseEntered(MouseEvent evt) { }
    public void mouseExited(MouseEvent evt) { }
    Now, this ALL works perfectly but the problem is i can only see the picture for a split second and then it disappears, i click the refresh button and i can see it again but then it goes again... I have tried commenting out the setBackground methods to no avail, i am so close has anyone got any ideas? and sorry for wasting u guys time with the other problem, my head isnt screwed on properly this week.
    Thanks in advance.

  • Place image on canvas

    Hi.
    I am trying to place image on canvas.
    However the image doesn't show!!!!!!!!!!!!! :(
    no error and compiles well....
    private void AddTile(String image, int startx, int starty, int endx, int endy)
    try{
    tiles = ImageIO.read(new File(image));
    catch(Exception e)
    System.out.println("Image not Found");
    Graphics2D a =(Graphics2D)tiles.getGraphics();
    a.drawImage(tiles, 20,20,20,20,TileCanvas);
    if the above function is called the image should be placed on canvas right?
    TileCanvas is a canvas, and tiles is BufferedImage.
    just in case I'll put my source code followed by this
    * MapEditor.java
    * Created on 2006�� 7�� 20�� (��), ���� 11:48
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.imageio.*;
    import java.io.*;
    * @author SeiKwon
    public class EditorComponent extends javax.swing.JFrame
    private java.awt.Button AddTile;
    private java.awt.Button DeleteTile;
    private javax.swing.JMenu FileMenu;
    private javax.swing.JMenuItem LoadFile;
    private javax.swing.JPanel ManageTilePanel;
    private java.awt.Canvas MapCanvas;
    private javax.swing.JMenuBar MenuBar;
    private javax.swing.JMenuItem SaveFile;
    private javax.swing.JScrollPane ShowMapScroll;
    private java.awt.Canvas TileCanvas;
    private javax.swing.JScrollPane TileScroll;
    private BufferedImage tiles;
    private int tilecount = 0;
    /** Creates new form MapEditor */
    public EditorComponent()
    initComponents();
    AddTile("test.jpg", 0, 0, 10, 10);
    private void initComponents()
    ManageTilePanel = new javax.swing.JPanel();
    TileScroll = new javax.swing.JScrollPane();
    TileCanvas = new java.awt.Canvas();
    AddTile = new java.awt.Button();
    DeleteTile = new java.awt.Button();
    ShowMapScroll = new javax.swing.JScrollPane();
    MapCanvas = new java.awt.Canvas();
    MenuBar = new javax.swing.JMenuBar();
    FileMenu = new javax.swing.JMenu();
    SaveFile = new javax.swing.JMenuItem();
    LoadFile = new javax.swing.JMenuItem();
    getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    ManageTilePanel.setLayout(null);
    ManageTilePanel.setBorder(new javax.swing.border.TitledBorder("Tiles"));
    TileCanvas.setBackground(new java.awt.Color(255, 255, 255));
    TileScroll.setViewportView(TileCanvas);
    ManageTilePanel.add(TileScroll);
    TileScroll.setBounds(10, 22, 100, 230);
    AddTile.setLabel("Add");
    ManageTilePanel.add(AddTile);
    AddTile.setBounds(10, 260, 50, 26);
    DeleteTile.setLabel("Delete");
    ManageTilePanel.add(DeleteTile);
    DeleteTile.setBounds(60, 260, 50, 26);
    getContentPane().add(ManageTilePanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 10, 119, 290));
    ManageTilePanel.getAccessibleContext().setAccessibleName("TilesPanel");
    MapCanvas.setBackground(new java.awt.Color(255, 255, 255));
    MapCanvas.addMouseListener(new java.awt.event.MouseAdapter()
    public void mouseEntered(java.awt.event.MouseEvent evt)
    MapCanvasMouseEntered(evt);
    ShowMapScroll.setViewportView(MapCanvas);
    getContentPane().add(ShowMapScroll, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 10, 290, 290));
    FileMenu.setText("File");
    FileMenu.setContentAreaFilled(false);
    SaveFile.setIcon(new javax.swing.ImageIcon("D:\\java\\MapEditor\\Image\\Save16.gif"));
    SaveFile.setText("Save");
    SaveFile.addActionListener(new java.awt.event.ActionListener()
    public void actionPerformed(java.awt.event.ActionEvent evt)
    SaveFileActionPerformed(evt);
    FileMenu.add(SaveFile);
    LoadFile.setIcon(new javax.swing.ImageIcon("D:\\java\\MapEditor\\Image\\Open16.gif"));
    LoadFile.setText("Load");
    LoadFile.addActionListener(new java.awt.event.ActionListener()
    public void actionPerformed(java.awt.event.ActionEvent evt)
    LoadFileActionPerformed(evt);
    FileMenu.add(LoadFile);
    MenuBar.add(FileMenu);
    setJMenuBar(MenuBar);
    pack();
    private void MapCanvasMouseEntered(java.awt.event.MouseEvent evt)
    Cursor cursorshape = MapCanvas.getCursor();
    MapCanvas.setCursor(cursorshape.getPredefinedCursor(CROSSHAIR_CURSOR));
    private void AddTile(String image, int startx, int starty, int endx, int endy)
    try{
    tiles = ImageIO.read(new File(image));
    catch(Exception e)
    System.out.println("Image not Found");
    Graphics2D a =(Graphics2D)tiles.getGraphics();
    a.drawImage(tiles, 20,20,20,20,TileCanvas);
    private void LoadFileActionPerformed(java.awt.event.ActionEvent evt)
    FileDialog fd = new FileDialog(this, "Open", FileDialog.LOAD);
    //fd.setFile("*.map");
    fd.setDirectory(".");
    fd.setVisible(true);
    String filename = fd.getFile();
    System.out.println(filename);
    private void SaveFileActionPerformed(java.awt.event.ActionEvent evt)
    FileDialog fd = new FileDialog(this, "Save", FileDialog.SAVE);
    //fd.setFile("*.map");
    //fd.setFilenameFilter("*.map"); // HOW TO USE?????????????
    fd.setDirectory(".");
    fd.setVisible(true);
    String filename = fd.getFile();
    System.out.println(filename);
    public static void main(String args[])
    java.awt.EventQueue.invokeLater(new Runnable()
    public void run()
    new EditorComponent().setVisible(true);
    }

    You have at least two problems.
    1) You are mixing AWT and Swing. Instead of using a Canvas you should use either a JComponent or a JPanel.
    2) In Swing, drawing such are you are doing should be done within the paintComponent(Graphics g) method using the Graphics provided as an argument to the method.
    P.S. I can't test you code because for some reason you feal the need to use a NetBeans specific layout manager.

  • OutOf Memory Error while saving image of canvas

    Hi,
    I am facing a weired problem while saving the image of the graphics in Canvas. It's giving me OutOfMemory error. Here is snippet of code:
    if(cmd.equals(C.ACTION_SAVE)){
                try {
                    FileDialog fd = new FileDialog(frame, "Save ProcessInstance as JPEG", FileDialog.SAVE);
                    fd.setFile(processInstance.getProcessDefinition().getName() +processInstance.getProcessOwner() +processInstance.getProcessOwnerId() +".jpeg");
                    fd.show();
                    String name = fd.getDirectory()+fd.getFile();
                        int w = canvas.getWidth(), h = canvas.getHeight();
                        BufferedImage image = new BufferedImage(w, h,
                                BufferedImage.TYPE_INT_RGB);
                        Graphics2D g2 = image.createGraphics();
                        canvas.paint(g2);
                        g2.dispose();
                        ImageIO.write(image, "jpeg", new File(name));
                    } catch (IOException e) {
                        System.err.println(e);
                    }

    Hi,
    I tried to run garbage collector for the same and now its working fine. I want to know is there any drawback of using this approach. I am new to java and waiting for ur expert comments. I added following lines in the above code just below ImageIO.write(image, "jpeg", new File(name));:
             image = null;
                        Runtime r = Runtime.getRuntime();
                        r.gc();

  • How to save an image from canvas to jpeg2000 format?

    good day! i would like some help about jj2000. i wish to save an image from canvas to a jpeg2000 format file. how will i do it using the jj2000? i just need to save it to a file.
    please help!!!
    thank you in advance!
    lrds

    I am not familiar with Jpeg2000, but the easiest way I've found to go from Java to a JPeg file is with Java Adavanced Imaging (JAI) package from Sun. Take a look at it and see if it meets your requirements.

  • Displaying images in canvas one after another

    Hi all,
    I have a problem displaying images in canvas one after another. I am using for loop and when i run the application, all images run back in the and only finally only the last image gets displayed in the emulator. I also used thread.sleep(). But it din't work.
    Here is my code:
    // A canvas that illustrates image drawing
    class DrawImageCanvas extends Canvas
    Image image;
    public void paint(Graphics g)
    int width = getWidth();
    int height = getHeight();
    g.setColor(0);
    g.fillRect(0, 0, width, height);
    String images[]={"paint_2.PNG","radha.PNG","cute.png","design.png","flowers.png"};
    for(int i=0;i<images.length;i++)
    image = null;
    System.out.println("/"+images);
         try
         image = Image.createImage("/"+images[i]);
    catch (IOException ex)
    System.out.println(ex);
    g.setColor(0xffffff);
    g.drawString("Failed to load image!", 0, 0, Graphics.TOP | Graphics.LEFT);
    return;
    if (image != null)
    g.drawImage(image, width/2, height/2, Graphics.VCENTER | Graphics.HCENTER);
    try
    Thread.sleep(5000);
    catch(Exception ex)
         System.out.println("the exception is.."+ex);
    Help me and Thanks in advance.

    See the code below : prefer the use of a Timer and a TimerTask instead of Thread.sleep().
    showNotify (from Canvas) is used to launch the timer.
    import java.io.IOException;
    import java.util.Timer;
    import java.util.TimerTask;
    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    public class DrawImage extends Canvas {
        Image image;
        String images[] = {"img1.png", "img2.png", "img3.png", "img4.png", "img5.png",
                            "img6.png", "img7.png"};
        Image[] tabImage;
        int imageCounter = 0;
        public DrawImage(){
            try {
                tabImage = new Image[images.length];
                for (int i = 0; i < images.length; i++)
                    tabImage[i] = Image.createImage("/" + images);
    } catch (IOException ex) {
    ex.printStackTrace();
    public void paint(Graphics g) {
    int width = getWidth();
    int height = getHeight();
    g.setColor(0);
    g.fillRect(0, 0, width, height);
    image = tabImage[imageCounter];
    if (image != null)
    g.drawImage(image, width / 2, height / 2, Graphics.VCENTER | Graphics.HCENTER);
    else{
    System.out.println("null");
    g.setColor(0xffffff);
    g.drawString("Failed to load image!", 0, 0, Graphics.TOP | Graphics.LEFT);
    protected void showNotify(){
    Timer t = new Timer();
    t.schedule(new PhotoSwitcher(), 5000, 5000);
    private class PhotoSwitcher extends TimerTask{
    public void run() {
    if (imageCounter < images.length - 1)
    imageCounter++;
    else
    imageCounter = 0;
    repaint();
    I hope this will help you !
    fetchy.
    Edited by: fetchy on 14 ao�t 2008 09:48                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to get transparency scroll bar to view background image of canvas.

    HI, 
    How to get transparency to path in canvas to view background image in canvas using scroll bar control.?
    This is my present output:
    My Xaml Code:
    <Grid Height="auto" Name="grid1">
    <TabControl Background="Bisque">
    <TabItem Header="Tools">
    <Grid Height="1000" Width="1000" Name="grid">
    <Border BorderThickness="0.2" BorderBrush="Black" Height="820" Width="820" ClipToBounds="True" Margin="90,99,90,81"></Border>
    <Grid>
    <Button Content="Original Size" Height="23" Name="btn_Original" Width="75" Click="btnOriginalSizePosition" Margin="4,4,921,973" />
    <TextBox Height="20" HorizontalAlignment="Left" Margin="62,49,0,0" x:Name="txtNoOfZones" VerticalAlignment="Top" Width="49"
    MaxLength="2" PreviewTextInput="txtNoOfZones_PreviewTextInput"/>
    <TextBox Height="20" HorizontalAlignment="Right" Margin="0,71,890,0" x:Name="txtSec" VerticalAlignment="Top" Width="49" PreviewTextInput="txtSec_PreviewTextInput" MaxLength="3"/>
    <Button Content="OK" Height="32" HorizontalAlignment="Left" Margin="117,59,0,0" Name="btnNoOfZones" VerticalAlignment="Top" Width="39" Click="btnNoOfZones_Click" />
    <Label Content="Zone Number selected :" Height="28" HorizontalAlignment="Right" Margin="0,0,451,0" Name="lblZone" VerticalAlignment="Top" />
    <Label Content="Sector Number in selected Zone :" Height="28" HorizontalAlignment="Right" Margin="364,22,451,0" Name="lblSector" VerticalAlignment="Top" />
    <Label Content="Filled Color applied in selected sector :" Height="28" HorizontalAlignment="Right" Margin="336,44,451,0" Name="lblColor" VerticalAlignment="Top" />
    <Label HorizontalAlignment="Left" Margin="569,0,0,0" Name="lblZoneNumber" Height="28" VerticalAlignment="Top" />
    <Label Height="28" HorizontalAlignment="Left" Margin="569,22,0,0" Name="lblSectorNumber" VerticalAlignment="Top" />
    <Label Height="30" HorizontalAlignment="Left" Margin="569,44,0,0" Name="lblFillColor" VerticalAlignment="Top" FontWeight="Bold"/>
    <Label Content="Sectors :" Height="28" HorizontalAlignment="Left" Margin="7,67,0,905" Width="69" />
    <Label Content="Zones :" HorizontalAlignment="Left" Margin="13,44,0,928"/>
    <TextBlock Height="23" HorizontalAlignment="Left" Margin="4,32,0,0" Text="Change No.of Zones, sectors below and click OK button" VerticalAlignment="Top" Width="294" FontFamily="Cambria" FontSize="12" FontStyle="Italic" FontWeight="Bold" />
    <RadioButton Content="Single Sector" Height="16" HorizontalAlignment="Left" Margin="744,24,0,0" Name="rBtnSingleSector" VerticalAlignment="Top" GroupName="Selection"/>
    <RadioButton Content="Sector Zone" Height="16" HorizontalAlignment="Left" Margin="744,44,0,0" Name="rBtnSectorZone" VerticalAlignment="Top" GroupName="Selection"/>
    <RadioButton Content="Circular Zone" Height="16" HorizontalAlignment="Left" Margin="744,64,0,0" Name="rBtnCircularZone" VerticalAlignment="Top" GroupName="Selection"/>
    <RadioButton Content="Panning" Height="24" HorizontalAlignment="Left" Margin="744,4,0,0" Name="rBtnPanning" VerticalAlignment="Top" Width="74" GroupName="Selection"/>
    <Border x:Name="clipBorder" BorderBrush="Black" BorderThickness="0" ClipToBounds="True" Height="810" Width="810" Margin="95,104,95,86" CornerRadius="10">
    <Canvas x:Name="CanvasPanel" Height="800" Width="800" Background="Transparent" ClipToBounds="True"></Canvas>
    </Border>
    <RadioButton Content="Random Color" HorizontalAlignment="Left" Margin="868,5,0,979" Name="rdBtnRandomColor" GroupName="rdbtnGroupFillColor"/>
    <RadioButton Content="Red Color" Height="16" HorizontalAlignment="Left" Margin="868,24,0,0" Name="rdBtnRedColor" VerticalAlignment="Top" GroupName="rdbtnGroupFillColor" Foreground="#FFF81010" FontWeight="Bold" />
    <RadioButton Content="Green Color" Height="16" HorizontalAlignment="Left" Margin="868,44,0,0" Name="rdBtnGreenColor" VerticalAlignment="Top" GroupName="rdbtnGroupFillColor" Foreground="#FF175F17" FontWeight="Bold" />
    <RadioButton Content="Adjacent" Height="16" HorizontalAlignment="Left" Margin="435,81,0,0" Name="rdBtnAdjacent" VerticalAlignment="Top" GroupName="Selection" />
    </Grid>
    </Grid>
    </TabItem>
    <TabItem Header="Change Background">
    <Grid Height="1000" VerticalAlignment="Top" Background="Bisque">
    <Button Height="70" Width="70" Margin="6,1,892,929" Name="btnBrowseImage" Click="btnAll">
    <Image x:Name="browseIcon" Source="D:\WPF\Projects\TabControlVRI_18_12_2014\Images\img.png" MouseLeftButtonDown="Image_MouseLeftButtonDown_1"/>
    </Button>
    <Button Height="70" Width="70" Margin="92,1,806,929" Name="btnCenterPoint" Click="btnAll">
    <Image x:Name="centerIcon" Source="D:\WPF\Projects\TabControlVRI_18_12_2014\Images\center.jpg" Width="54" Height="48" />
    </Button>
    <Button Height="70" Width="70" Margin="179,1,719,929" Click="btnAll">
    <Image x:Name="boundaryIcon" Source="D:\WPF\Projects\TabControlVRI_18_12_2014\Images\Path_Simple.png" Height="44" Width="49" />
    </Button>
    <Image Name="imgBackground" Height="800" Width="800" MouseLeftButtonDown="imgBackground_MouseLeftButtonDown">
    </Image>
    </Grid>
    </TabItem>
    </TabControl>
    </Grid>
    C# code:
    OpenFileDialog op = new OpenFileDialog();
    ImageBrush ib = new ImageBrush();
    private void Image_MouseLeftButtonDown_1(object sender, RoutedEventArgs e)
    op.Title = "Select a picture";
    op.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" +
    "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" +
    "Portable Network Graphic (*.png)|*.png";
    if (op.ShowDialog() == true)
    ib.ImageSource = new BitmapImage(new Uri(op.FileName));
    imgBackground.Source = new BitmapImage(new Uri(op.FileName));
    CanvasPanel.Background = ib;
    Please help me out to get transparency for path in canvas to view background image in canvas.
    The complete code is in below link:
    https://onedrive.live.com/redir?resid=876CFAE94C306176!112&authkey=!AC1sQIYwyoRYT_o&ithint=file%2crar
    Regards,
    Viswa.

    Hi ViswAmmu,
    >>Please help me out to get transparency for path in canvas to view background image in canvas.
    If I'm not misunderstanding, I think you just need to loop through all Canvas.Children and set Opacity property for them:
    private void Image_MouseLeftButtonDown_1(object sender, RoutedEventArgs e)
    //Loop through all children items
    foreach(UIElement v in CanvasPanel.Children)
    v.Opacity = 0;
    op.Title = "Select a picture";
    op.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" +
    "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" +
    "Portable Network Graphic (*.png)|*.png";
    if (op.ShowDialog() == true)
    ib.ImageSource = new BitmapImage(new Uri(op.FileName));
    imgBackground.Source = new BitmapImage(new Uri(op.FileName));
    CanvasPanel.Background = ib;
    Screenshot:
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Can anyone explain me how to scale the image in canvas in flash builder 4.6

    Can anyone explain me how to scale the image in canvas in flash builder 4.6, Scaling of image in component , can i get some examples ..  it should set almost all size screen

  • Dropping image on canvas causes image to jump.

    When I drop an image on a canvas in AIR the image "jumps" a few pixels to several from the current mouse location.
    So if the mouse is at location (12, 12) and I drop the image it may appear at (10, 14), or (15, 20), or whatever. It doesn't appear to be a consistent offset like I would expect if this were caused by using global to local mouse position thing (but I'm not ruling that out anyway).
    Secondly, when I then drag to move the image on the canvas the drag proxy will again jump many pixels from the mouse cursor.
    Here is my mouse down handler:
                private function dragBegin(event:MouseEvent):void
                      var dragInitiator:Image = Image(event.currentTarget);
                    var ds:DragSource = new DragSource();
                    ds.addData(dragInitiator, "img");   
                    var dragProxy:Image = new Image();
                    dragProxy.source = event.currentTarget.source;
                    DragManager.doDrag(dragInitiator, ds, event, dragProxy);
    And the drop handler:
            private function dragDropHandler(event:DragEvent):void
                   var image:Image = Image(event.dragSource.dataForFormat("img"));
                   image.x = event.localX;
                   image.y = event.localY;
                   UIComponent(event.currentTarget).addChild(device);
    What am I doing wrong that is causing this jumping?
    Thanks,
    -Mark

    Hi,
    I think the only way to do this is to use a jsp with a servlet, where the servlet would create the image and send it over as a stream, while the jsp would call on the link of the servlet and display that image using the HTML <IMG> tag.
    So, if you have a servlet, lets call it PictureServlet.
    This is what you would do in your servet:
    // create that image and send it over from the doPost/doGet method of the servlet
    public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("image/jpg"); // set the stream to be a JPEG image
    ServletOutputStream sos = response.getOutputStream(); // create the output stream
    BufferedImage bImg = createImage(); // this is where you write on your image using canvas and return it as a Bufferedimage
    ImageIO.write(bImg,"JPG",sos); // write the image to the stream as JPEG
    sos.close(); // close the output stream
    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            doPost(request, response);
        } This is how you would get that image and display it in your JSP.
    <img src="../servlet/PictureServlet" name="pic">Note the path might be different, depending on the hierarchy of where jsps and servlets are stored on the server.
    I hope this helps,
    Val.

  • After Effects  clear images cache programmatically?

    hi,
    i'm currently developing an AE effect plugin.
    i want to be able to clear the cache programmatically
    from my effect plugin code.
    is there any way to do this?
    thanks in advance!

    Hi,
    May I ask why you need to clear image cache from your effect plug-in?
    It may be a bug (either in Plug-in or AE) if you need to do so for some reason.
    I can read Japanese, if you prefer to use Japanese.
    Thanks,
    -keiko

  • How to fit image inside canvas Container?

    Hi All,
    I want to fit an image inside a canvas.
    Making x and y to 0 of image is not working.
    My problem is I am rotating image at 90 and I want to save that image. If i save normally it is not taking rotation.
    So I am adding that image in a canvas and saving that canvas with rotated image.
    Somehow some portion of canvas still remains empty after adding image to it.
    Any idea how to perfectly fit image inside canvas?
    Or How to rotate image bitmap data with maintainig aspect ratio?
    Thank in advance

    Mx component don't handle rotation very well.  Spark Group should handle it
    better.
    You may need to set the y to the height of the rotated image (its original
    width).

  • Image on canvas prob...

    Is there any way to know that whether an image is present at particular location on canvas or not?
    Actually, i have written a code that draws image on canvas and moving it randomly. I have to keep checking how many times the image passes through a rect area at particular location.....
    ...........Its a part of my project ..Plz help me out!

    Make a Rectangle with width and height equal to the moving image dimensions. Move/position the rectangle from your event code and draw the image at its origin (x,y). Then it is a simple matter to check for intersection between this moving rectangle and the target rectangle.

  • Right click top bar to open Image Size/Canvas Size/Info?

    I've just upgraded from PS 5 to PS CC. In previous versions I was able to just right click on the top image bar to bring up a dialog box allowing me to access the Image Size, Canvas Size, Image Info, etc... That does not seem to be the case with PS CC, or am I missing a prefence setting that will allow this?
    Thanks!

    I tried your suggestion but still cannot access that info by right-clicking the bar. I've gone through my preference settings, primarily under the Interface section and enabled and disabled several options but still no luck. It's just habit from many years use and nice to be able to access several common settings I might adjust.
    The keyboard shortcuts are fine also, but again habit and if my hand is already on the mouse it's just...or was just a simple click. (Me being lazy)
    Thanks for the help and suggestions. If anyone else a suggestion, great!

  • Image in canvas

    I did something wrong then i can't see the image in canvas when i'm not playing the video in timeline. It's very hard to edit without viewing changes in canvas. Im a beginner, I need your help.
    Thank You
    Adolfo

    Hello
    At first, image diapeared, canvas was white; after i commit my second error because i tried using toggling channels, image went sepia or red
    Thank you
    Adolfo

Maybe you are looking for

  • Installation error during creation of user SAPJSF

    Hello, i'm performing SOLMAN installation and the installation stops in "Import Abap" step with problem creating the SAPJSF user. Several posts regarding the same error did not helped. When the sapinst is trying to create the SAPJSF user, i notice th

  • How do I restore "Preview" 2.1.0 (V211) application for 10.3.9 system?

    My old application got corrupted and I need to reinstall that application. Where can I find the PREVIEW application mentioned?

  • Querry over pricing procedure used in creation of BIlling request

    Hi,      While creation of BIlling request via DP90 , system considers DIP Profile & pricing procedure and brings data /rates to billing procedure .. I am trying to understand the pricing procedure, i am using standard pricing procedure RVAA01 -> Whe

  • Force quit Preview after Maverick

    I installed Mavrick about 3 weeks ago and have had nothing but trouble. I am having to force quit some program everyday; preview (being the worst), finder, numbers, whatever. Preview will open the document but then I can't scroll and have to force qu

  • User exit during creation of notification

    Hello! I am creating a notification. Required start date and time is mandatory. Now I want that difference between notification creation date and required start date should not exceed 30 days. This can be achieved by user exit. Which user exit should