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.

Similar Messages

  • 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!

  • Multiple image upload CRASH!!! but works with simple image upload

    I'm getting MAD.
    I'm using php and GD
    While the simple image and re size works like a charm, the multiple image upload or the multiple file upload have a strange behavior.
    It opens the pop-up with flash, then eventually shows me files or thumbnails but when I try to up load I just wait and get the typical "system becoming unstable" flash error.
    As I can see the directory is always generated (I've tried also to put a static directory) but after stargin the upload the flash uploader just crashes and no result.
    Any help would be really appreciated

    Hi Fonzie,
    as the folder is getting created, the issue you´re having is not related to wrong folder permission - it´s something else...
    As I wrote before, che common upload and resize function works perfectly
    this one works perfectly, because it´s just one file to upload and to process, wheras doing that with multiple files might collide with some settings on your server
    So for sure it's not a simple issue as the max filesize
    Are you sure ? Did you check the current "max_upload_filesize" setting ? As long you don´t check it, you can´t know :-)
    As a general rule of thumb, it´s important to be aware of the fact that uploading & resizing images on the server might collide with several PHP settings -- and the more images you upload and resize in one swoop, the closer you´re getting to these limits respectively might even be exceeding them. The following "directives" are those which have an effect on whether your image/file upload & processing will work or not:
    - "max_upload_filesize" :: is sometimes set to just 8 MB on a shared hosting, sometimes 16 MB, sometimes more. This setting will affect the file upload procedure only
    - "set_time_limit" (e.g. 30 seconds) :: if the execution time of a script exceeds this limit for whatever reason, the server simply shuts it down without letting you (respectively the flash uploader) know it´s been shut down. This *might* be the reason why ADDT´s flash uploader hangs respectively returns that error message after some time, because it´s waiting for some response from the server which never comes.
    - "memory_limit" (e.g. 8 MB) :: this directive is a sort of "allocated server RAM" for your account, and it´s in particular the image resizing process which will grab more or less memory resources -- the higher the the resizing factor is, the more RAM is spent, and the more images are getting resized in one swoop, the worser it gets.
    However, all these PHP directives can be changed, and your host might even be so courteous to increase the currently defined values of those abovementioned directives for you -- and that´s what I´m suggesting at this point.
    Cheers
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • 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.

  • Why does Illustrator on Windows 7, 64bit, take 30seconds+ to save a simple image?

    This question is for Adobe Customer Service, thanks. 
    Why does Illustrator on Windows 7, 64bit, take 30seconds+ to save a simple image comprising of two rectangles only (screen shot below)?  I set up a document like this to test the speed, since I've been having trouble saving all documents - they hang, sometimes with the 'this program is not responding' message.   Switching to CC is not an option.
    If it helps, I can come down to the Adobe San Francisco office with my computer.  I've spent a long time trying to resolve this without success.
    Btw, Photoshop CS6 saves fine.
    Thanks again.

    knot,
    Customer Care is over there:
    I believe this is one for Customer Care (tick I Still Need Help and hope for an agent available for a chat),
    http://helpx.adobe.com/contact.html?product=illustrator&topic=downloading-installing-and-s etting-up
    Sometimes staff appear here.
    We are just the natives.
    Can you create artwork without delays?
    Is there a printer (driver) set up?
    Are you saving to own harddisk (recommended) or somewhere else?

  • 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.

  • Simple image rotation

    Hi all,
    Have a couple of pages on a site i'm building where i need a simple image rotation / image swap.
    It doesn't have to be anything flash, it's purely for a 200px square image to automatically swap every 5 seconds or so. It doesn't need any user buttons to go to next / previous, or enlarge when clicked.
    I've tried a couple of free jquery ones, but these won't load the starting image until all the images have been loaded into the browser, so you end up with a blank spot, then after say 10 seconds the images appear.
    Looking through the programs forums, it seems that the jquery i'm downloading isn't configurable to preload the images, so maybe i'm going down the wrong route completely!
    Whats the best / simplest way to do this and can you recommend anywhere to read up on how to implement it?
    Thanks
    Dan

    Dan, download the cycle plugin pack first: http://jquery.malsup.com/cycle/download.html. You can copy/ paste in a new .js file and store it locally on your site folder. Or, you could also use the cloud link as I've given below. Both will work.
    Then, include the jQuery library to before closing your </head> tag:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
    Now, include the jQuery cycle plugin library before your </head> tag:
    <script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js"></script>
    Define the DIV that will animate with cycle plugin before your </head> tag:
    <script type="text/javascript">
    $(document).ready(function() {
        $('.slideshow').cycle({
    fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    </script>
    In the above code, Div with class slideshow will keep cycling with a fade effect. Note that for some effects to work, you may require the jquery easing plugin. But, fade will do just fine for your original question.
    Then, structure your image container:
    Based on your original code:
    <p class="pagetext">    <img src="images/hgsindeximg1.png" alt="School pupils" width="300" height="233" class="fltrt">Welcome  to our school website, we hope that you enjoy looking around the site. <br>
        </p>
    You have to restructure it this way:
    <p class="pagetext">
    <div class="slideshow">
    <img src="images/hgsindeximg1.png" alt="School pupils" width="300" height="233" class="fltrt">
    <img src="images/hgsindeximg2.png" alt="School pupils" width="300" height"233" class="fltrt">
    <img src="images/hgsindeximg3.png" alt="School pupils" width="300" height"233" class="fltrt">
    </div>
    Welcome  to our school website, we hope that you enjoy looking around the site. <br>
        </p>
    In the above code, I've added 2 more images that will rotate on your page. Change the filenames to whatever you desire. Also, ensure you retain the image dimensions same across all 3 images for best results.
    If you notice, I've just moved the images into a DIV called 'Slideshow'. As defined previously, all 3 images with <img..> within the div with class slideshow will keep rotating.
    On a sidenote, please please please please change the background color from red to something 'non-distractive'! Seriously, I went searching for moisturizing drops for my eyes once I opened up the test page you had posted!
    Trust this helps.

  • Simple Image Gallery for iWeb

    Hi there,
    Hoping someone can help. I've been searching high and low for an incredibly simple image web gallery generator. It simply has to have a larger image to the left and 3/4 smaller thumbnails to the right which, when clicked on, will appear in the bigger window. That's it! I don't want any text on it at all - just on a white background. The intention is to then upload the individual galleries of my work and use iFrames within my iWeb created website to point towards the galleries.
    Please can anyone help and point me in the direction of a good bit of software that will allow me to do this. I have no HTML experience to speak of.
    Thanks
    Sam

    Sam ~ This +"HTML Picture Viewer"+ would be easiest to implement using iWeb '08's +HTML Snippet+ window:
    http://web.mac.com/catucker/InsideOutside/PictureViewer.html
    ...it has the larger image to the right, but I suppose someone here could tell you how to reverse that. And the image changes not on a click of a thumbnail, but on mouseover.

  • Creating a simple image application in Apex

    select
    "IMAGE_ID",
    <img src="#OWNER#.deliver_thumbnail?p_image_id='||IMAGE_ID||'"/> thumbnail,
    "FILENAME" from "ORDIMAGE_IMAGES"
    where
    instr(upper("FILENAME"),upper(nvl(:P1_REPORT_SEARCH,"FILENAME"))) >
    Its is showing an error
    showing only the coding part when i run the application instead of showing image....
    can you please help me rectify the error
    Edited by: 880021 on 17-Aug-2011 20:58

    Creating a simple image application in Apex
    Create a new application from scratch. Name it ORDImages_images.
    Add a Report and Form Page based on your ORDImage_images table. Ensure that you select a Classic Report (i.e. not Interactive, which is the default). As expected, two pages are created.
    Continue to create the application and then run it.
    After the login page, there will be spurious entries for image and thumbnail.
    This is expected because of the ORDImage columns in the images table.
    Edit Page 1 and open the Images Region
    The Source entry is
    select
    "IMAGE_ID",
    "IMAGE",
    "THUMBNAIL",
    "FILENAME"
    from "ORDIMAGE_IMAGES"
    where
    instr(upper("FILENAME"),upper(nvl(:P1_REPORT_SEARCH,"FILENAME"))) > 0
    In SQL Developer, create the deliver_images_thumb procedure
    CREATE OR REPLACE PROCEDURE deliver_thumbnail(p_image_id IN NUMBER) IS
    l_thumbnail ORDSYS.ORDImage;
    BEGIN
    -- Fetch the thumbnail from the database
    SELECT thumbnail
    INTO l_thumbnail
    FROM ORDImage_images
    WHERE image_id = p_image_id;
    -- Check update time if browser sent If-Modified-Since header
    IF ordplsgwyutil.cache_is_valid( l_thumbnail.getUpdateTime() )THEN
    owa_util.status_line( ordplsgwyutil.http_status_not_modified );
    RETURN;
    END IF;
    -- Set the MIME type and deliver the image to the browser.
    owa_util.mime_header( l_thumbnail.mimeType, FALSE );
    ordplsgwyutil.set_last_modified( l_thumbnail.getUpdateTime() );
    owa_util.http_header_close();
    IF owa_util.get_cgi_env( 'REQUEST_METHOD' ) <> 'HEAD' THEN
    wpg_docload.download_file( l_thumbnail.source.localData );
    END IF;
    END;
    Then
    GRANT EXECUTE ON deliver_thumbnail TO PUBLIC;
    Return to Apex and change the Source entry to
    select
    "IMAGE_ID",
    '<img src="#OWNER#.deliver_thumbnail?p_image_id='||IMAGE_ID||'"/>' thumbnail,
    "FILENAME" from "ORDIMAGE_IMAGES"
    where
    instr(upper("FILENAME"),upper(nvl(:P1_REPORT_SEARCH,"FILENAME"))) > 0
    Apply changes and run the application
    You can now search on substrings of filenames. Note that the image_ID is not shown. To rectify this, Edit Page 1 and open Report in Regions.
    Edit the image_id and under Column Link, change the Link Text to #IMAGE_ID#. Also change the Heading in the Column Attributes to Image ID.
    Apply the changes and re-run.
    Clicking on the image_id link takes you to Page 2 – the form for that image.
    Page 2 is sparse so reveal the image_id by Editing Page 2 and opening the P2_IMAGE_ID Page Item. Change Display as Hidden to Text Field. Apply changes and re-run.
    In Page Items, open and delete the P2_THUMBNAIL item.
    Open the P2_IMAGE item.
    Under Name, change the Display As entry to Display Image (from the select list).
    Under Settings, change the Based On entry to BLOB Column returned by SQL Statement
    Enter
    SELECT i.image.source.localdata
    FROM ORDimage_images i
    WHERE image_id = :P2_IMAGE_ID
    as the SQL Statement
    Apply changes and re-run the application
    Making an image clickable
    Edit Page 1 and open Report in Regions. Edit THUMBNAIL and under Column Link, insert
    <img src="#OWNER#.deliver_thumbnail?p_image_id=#IMAGE_ID#"/>
    as Link Text.
    Select Page 2 as the Target Page in this Application.
    Finally, set Item 1's name to P2_IMAGE_ID and its Value to #IMAGE_ID#
    Removing the Spreadsheet link
    Under Report Attributes, set Enable CSV Output to No

  • 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.

  • Problem w/saving simple image as .png

    Hello:                                                                                                                            Level: Newbie'ish   OS: Win7 64bit   PS: CS6
    I have been making a simple image of a 300 by 100 rounded rectangle and then adding various layer styles. Basically I am makeing mobile headers which will be used for mobile websites.
    Today I was reviewing  a few that I have made and noticed that when I open them in their .png format and then create a selection around one (Ctrl + Click) that the lower right coner is not being selected as rounded but as a point and so when I copy and then paste it into a new document it has three rounded corners and one somewhat visible pointed corner.  ?? ??
    The file has a BG layer and two shape layers (or sometimes just one shape layer). I select the layers and then merge them together and turn off the BG layer beofore I save them for the web. I have also tried just saving the file as a .png w/out merging the layers but no matter how I go about saving the file(s) most of the time one corner is saved w/that annoying and imperfect sharp corner.
    Any ideas? Your time is greatly appreciated ~ Thanx a Bunch!!

    Hey c.pf...
    sorry for just getting back ~ the holiday season has me run'n Crazy.
    any way, i figured out my problem. i hadn't realized that i accidentally clicked the outer glow option and it was so faint that i couldn't see it all that well or actually ~ at all until i went back through the LS ...
    so, when i would save the image (mobile header) it was including or making room for the outer glow
    funny how something so simple can be overlooked.
    well, sorry for bothering ya over nothing ~ but i really appreciate your willingness to help me out
    hope all is well!! thanx again!

  • 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

  • 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.

Maybe you are looking for