How to save image which is inside an applet?

In my web application, I am displaying some graphs using applet. I wish to let the user save the graphs as images from the browser.
I would really appreciate if somebody could inform me about this.
Thanks
Sachin

A couple of things...
1) You will need to sign your applet afterwards, otherwise the user will not be able to save the graphic to their hard drive due to the Java security policy.
2) I did something similar, a code snippet is below. Mine was a Servlet version though, and sent the buffered stream to a JSP page where it was displayed as a graphic. You can figure out how to modify this so that it goes to a File stream instead... You will
OutputStream stream;
BufferedImage bi = new BufferedImage(pieValueObject.getCanvasWidth(),                          pieValueObject.getCanvasHeight(),
BufferedImage.TYPE_BYTE_INDEXED);
Graphics2D graphics = (Graphics2D)bi.createGraphics();
// paint all your stuff on the graphics object created above
// use a JPEG encoder to actually take what is on the graphics
// object inside the BufferedImage, and encode it to the stream.
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(stream);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
param.setQuality(1.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(bi);
// Your graphic is now in the Output stream.

Similar Messages

  • How to reference an image which is inside of ArrayList?

    Hi,
    I have an item renderer which displays an image.
    When image is loaded from file I'm just using this : <mx:Image source="...
    But how to to reffer the image data (png images) which are inside of  ArrayList ?
    Thanks!

    Taking a guess here:
    <mx:Image source="{myList.getItemAt(3)}">
    Or
    <mx:Image id="someImage">
    then in ActionScript:
    someImage.source = myList.getItemAt(3);

  • I want to renew my window and how to save backups which i hav on my itunes ??

    i want to renew my window and how to save backups which i hav on my itunes ??

    See Backup your iTunes for Windows library with SyncToy. As long as you copy your entire library over to the new/rebuilt computer your devices should sync with the library and will be backed up on the first sync. If you really want to backup the device backups see this support document iTunes: About iOS backups and backup the device backup folders, then restore them into your new profile.
    tt2

  • How to save image files into SQL Server?

    Hello, All:
    Does anyone know how to save image files into SQL Server? Does the file type have to be changed first?? Please help me! Thank you!

    You need a BLOB field (usually)... Then you can check this tutorial out:
    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/exercises/BLOBPut/
    There are other exercises on that site, including one on reading the images back.

  • How to save image catch from USB camera to database ?

    Hi guys.
    I needed help on IMAQdx tools. But i dont know how to save image that catch from USB camera to database.

    So you can acquire the image OK?
    And you want to save it to a SQL database?
    See here:
    http://zone.ni.com/devzone/cda/epd/p/id/5210

  • E61i -- HOW TO SAVE IMAGES FROM WEBSITE WHILE BROW...

    ANYBODY KNOWS HOW TO SAVE IMAGES FROM WEBSITE WHILE BROWSING IN E61i ???
    ABDULLAH SHAHID SHEIKH
    IMANGROUP, IMAN ROAD, NOORPUR, ALI BLOCK, MUSLIM TOWN, FAISALABAD, PAKISTAN.
    TEL. 0092418782792-93
    CELL. 00923008651424

    which version should i use ,, i mean suitable for my E61i,,, the opera mini or the opera mobile????
    is opera mini can save the images as well???
    25-Aug-200702:43 PM
    iantaylor27 wrote:
    Hi
    If you use opera mobile, it aloows saving of images to memory card etc
    www.opera.com
    ABDULLAH SHAHID SHEIKH
    IMANGROUP, IMAN ROAD, NOORPUR, ALI BLOCK, MUSLIM TOWN, FAISALABAD, PAKISTAN.
    TEL. 0092418782792-93
    CELL. 00923008651424

  • How to Save image in a text to my photos

    How do I save the photo in a text message to my iPad air photos?

    Tap the image in Message. (If you touch too long it brings up the: Copy; Other... menu instead)
    This blows the image up to full screen.
    Touch the image again to get menu options.
    In the top right corner, tap the box with the up arrow.  One choice is Save Image.  Touch it to save to your camera roll.
    In the top left corner, the three-line menu shows you all the photos in the message string, and some metadata like image size and camera title/image number.
    This is in IOS 7.1.1 on an iPad, and should work on iPhone and Touch also.

  • How to save image in database

    hi ,
    I am developing a application. i want to upload image with person's details and save it to database. How to do this? I hv got tutorials for uploading image but want to know how to save it to database table along with person's details.
    Thanks in advance.
    Regards
    Rajaram

    1.Go to transaction SE78.
    2.Select tree menu: Form Graphics -> Stroed on Document Server -> Graphics General Graphics -> BMAP Bitmap Images
    3.Select <IMPORT> to import bitmap image file to SAP. System will popup screen for input file information and target name.
    4.Select <Tick> After you already input data. System will upload image and return message to tell you success or fail.
    5.You can preview the picture that uploaded by select<print prv>
    If u want to store the images and retrive it from the server corresponding to the person id then just save the image by person id and code it as per the requirement.
    U can save ur images using se78 and also u can c it using TCODE AL11.By navigating thru the exact path u can get the images.

  • How to save image to local machine

    how to save my drawing (image or movieclips) to my local sytem without any server side script . i m using player 10. Please share some example

    I don't think that will bwe possible
    As that will be a hack in terms of an internet user.
    However usual solution to this is save your file at server and give user a bitton or some interface to download it

  • How to save Image from binding FlipView?

    I bind 4 images in my FlipView, how save an binding Image to Picture Library;
    <FlipView Name="display1"  ItemsSource="{Binding}" Foreground="#FFE6D52E" HorizontalAlignment="Center" VerticalAlignment="Center           
                <FlipView.ItemTemplate>
                    <DataTemplate>                  
                                <Image x:Name="image" Source="{Binding  Path=Image}" Stretch="UniformToFill"/>                
                    </DataTemplate>
                </FlipView.ItemTemplate>
            </FlipView>
    private void SaveImage_Click(object sender, RoutedEventArgs e)
                  var img = display1.SelectedItem as WriteableBitmap;
                           StorageFolder appfolder = await   KnownFolders.PicturesLibrary.CreateFolderAsync("myimage",          
    CreationCollisionOption.OpenIfExists);
            StorageFile myFile = await appfolder.CreateFolderAsync("imge1.jpg", CreationCollisionOption.ReplaceExisting);    
            img.Invalidate();
            using(Stream strem = await myFile.OpenStreamForWriteAsync())
                img.Savejpeg(strem, img.PixelWidth, img.PixelHeight, 0, 100);
    //for me it is  hard to save binding files,I cant save any image

    Hi Icce cage,
    Per my understanding, you bind the path of image to Image control, so you get image path string from display1.SelectItem property. Try finding Image from this path in installation folder and then copy it to Picture library. Please try the following code
    snippet.
    Custom class to hold the image object.
    public class CustomClass
    public string ImagePath { get; set; }
    public string ImageName { get; set; }
    Initial image sources.
    private void Page_Loaded(object sender, RoutedEventArgs e)
    images = new System.Collections.ObjectModel.ObservableCollection<CustomClass>();
    images.Add(new CustomClass() { ImagePath = "/Images/1.png", ImageName = "1.png" });
    images.Add(new CustomClass() { ImagePath = "/Images/2.png", ImageName = "2.png" });
    images.Add(new CustomClass() { ImagePath = "/Images/3.png", ImageName = "3.png" });
    images.Add(new CustomClass() { ImagePath = "/Images/4.png", ImageName = "4.png" });
    images.Add(new CustomClass() { ImagePath = "/Images/5.png", ImageName = "5.png" });
    display1.ItemsSource = images;
    XAML.
    <FlipView RightTapped="display1_RightTapped" Name="display1" Foreground="#FFE6D52E" HorizontalAlignment="Center" VerticalAlignment="Center" >
    <FlipView.ItemTemplate>
    <DataTemplate>
    <Image x:Name="image" Source="{Binding Path=ImagePath}" Stretch="UniformToFill"/>
    </DataTemplate>
    </FlipView.ItemTemplate>
    </FlipView>
    Save image to picture library.
    private async void display1_RightTapped(object sender, RightTappedRoutedEventArgs e)
    CustomClass data = display1.SelectedItem as CustomClass;
    if (data!=null)
    var installation = Windows.ApplicationModel.Package.Current.InstalledLocation;
    var imagesfolder =await installation.GetFolderAsync("Images");
    var file = await imagesfolder.GetFileAsync(data.ImageName);
    await file.CopyAsync(KnownFolders.PicturesLibrary);
    Regards,
    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.

  • How to "Save Image" directly instead of "Save Image As"?

    Is there anyway or option to directly save images instead of having to click "save image as" then go into the popup to save the image location? Thank you!

    Gingerbread Man made good suggestions.
    However you still must "save as" something even if "unnamed001". Windows requires a name and location for each file (whether an image or other file) saved. You can have the same file name in different directories (folders).
    You can copy and paste images without saving, in some applications.

  • How to convert images which is not supported by the ImageIO?

    I have made one project.
    In that i have used some images and render them on some screen.
    Now there are many images which is not supported by the ImageIO class bcz its showing me exception like
    javax.imageio.IIOException: Unsupported Image Typeso what to do to render this images or can i convert this kind of images to supported images?
    is there anything which can render this kind of images.
    Edited by: Nitz_09 on May 24, 2010 2:12 AM

    CR2 files from which Canon camera?
    Supported cameras are listed here
    Camera Raw plug-in | Supported cameras

  • How to save image from email to iPhoto

    trying to save image attachment from email to iPhoto

    What is the problem? What does not work?
    Either drag the attachment from the mail to the iPhoto con in the Dock, or ctrl-click the attachment and use the option "Export to iPhoto" from the pop-up menu (in Mail in MacOS X 10.10). Don't remember, if this worked in Mail in Mac OS X (10.5.8), as your signature is showing.

  • Problem with how FeuerFuchs saves images

    FeuerFuchs presently seems to work like this. You load a page displaying an image or images. You like one or more of them and you want to save them. Each time you tell FeuerFuchs to save an image, instead of copying that image from wherever it's stored in order to display it on your screen to the folder you want to save it to, FeuerFuchs re-downloads that image.
    Can someone please tell me why FeuerFuchs is programmed to re-download images it's told to save instead of copying them from wherever they're stored in order to display it on the screen? It seems like that only serves to increase bandwidth usage.

    I've got that and it's great for if I want to save all the images from one or more tabs. But it only saves images from entire tabs instead of one out of several images in a tab and the treeview navigation is slower than using the shortcuts I use to jump from one folder to the next.

  • How to save image?

    Hi all,
    I have drawn an Image using Graphics, and then I have drawn some rectangles on it.
    How can I save that image with drawn rectangles?
    any idea or link which should I refer?

    Example 1:
    import java.awt.BasicStroke;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.FontMetrics;
    import java.awt.GradientPaint;
    import java.awt.Graphics2D;
    import java.awt.geom.Ellipse2D;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    public class WriteImageType {
      static public void main(String args[]) throws Exception {
        try {
          int width = 200, height = 200;
          // TYPE_INT_ARGB specifies the image format: 8-bit RGBA packed
          // into integer pixels
          BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
          Graphics2D ig2 = bi.createGraphics();
          Font font = new Font("TimesRoman", Font.BOLD, 20);
          ig2.setFont(font);
          String message = "www.java2s.com!";
          FontMetrics fontMetrics = ig2.getFontMetrics();
          int stringWidth = fontMetrics.stringWidth(message);
          int stringHeight = fontMetrics.getAscent();
          ig2.setPaint(Color.black);
          ig2.drawString(message, (width - stringWidth) / 2, height / 2 + stringHeight / 4);
          ImageIO.write(bi, "PNG", new File("c:\\yourImageName.PNG"));
          ImageIO.write(bi, "JPEG", new File("c:\\yourImageName.JPG"));
          ImageIO.write(bi, "gif", new File("c:\\yourImageName.GIF"));
          ImageIO.write(bi, "BMP", new File("c:\\yourImageName.BMP"));
        } catch (IOException ie) {
          ie.printStackTrace();
    Example 2:
    // Create an image to save
        RenderedImage rendImage = myCreateImage();
        // Write generated image to a file
        try {
            // Save as PNG
            File file = new File("newimage.png");
            ImageIO.write(rendImage, "png", file);
            // Save as JPEG
            file = new File("newimage.jpg");
            ImageIO.write(rendImage, "jpg", file);
        } catch (IOException e) {
        // Returns a generated image.
        public RenderedImage myCreateImage() {
            int width = 100;
            int height = 100;
            // Create a buffered image in which to draw
            BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
            // Create a graphics contents on the buffered image
            Graphics2D g2d = bufferedImage.createGraphics();
            // Draw graphics
            g2d.setColor(Color.white);
            g2d.fillRect(0, 0, width, height);
            g2d.setColor(Color.black);
            g2d.fillOval(0, 0, width, height);
            // Graphics context no longer needed so dispose it
            g2d.dispose();
            return bufferedImage;
        }

Maybe you are looking for

  • Export data to a flat file

    Hi all, I need to export a table data to a flat file. But the problem is that the data is huge about 200million rows occupying around 60GB of space If I use SQL*Loader in Toad, it is taking huge time to export After few months, I need to import the s

  • Non scrolling region with watermark in RH-HTML?

    Hello, I always worked with RoboHelp for word and would like to try and import everything into HTML-Projekts. I don't have any experience with it and can't find some functions. Is it possible to define a non scrolling region for the heading of my htm

  • Is it possible to slip and angle in multi cam?

    When cutting multicam, some times the 2nd camera may find the interviewee not looking great, he might be picking his nose or looking uninterested. In legacy FCP7 it was posssible to slip that camera angle to a point when the interviewee was looking m

  • How can i print on reg paper instead of photo paper?cc=us

    if i try to email or send something to the printer, it will not print on regular paper.  it asks to put paper in the photo tray.  is there a way to have it print from the regular paper tray?

  • Retrieving tags and corresponding text within textFrame

    I have a text frame that looks like this: starting with a reference to the pageitem, I want to be able to get a list of the tag names and the text that corresponde to them. In this example the red tag is "text1" the green tag is "text2" and the blue