Saving an image in a png format

Hi,
I am creating a simple applet for avatar-making. You can choose face, hair, eyes, etc and then save it to a disc as a png file. The simple version (without the interface for the simplicity purpose) looks like this:
import java.awt.*;
import java.applet.*;
import java.net.*;
public class Example extends Applet
     Image my_gif;
     Image my_gif2;
     URL base;
     MediaTracker mt;
     public void init()
            mt = new MediaTracker(this);
         try {
                 base = getDocumentBase();
         catch (Exception e) {}
           my_gif = getImage(base,"1.gif");
           my_gif2 = getImage(base,"2.gif");
           mt.addImage(my_gif,1);
           mt.addImage(my_gif2,2);
          try {
               mt.waitForAll();
          catch (InterruptedException  e) {}
     public void paint(Graphics g)
           g.drawImage(my_gif,0,0,this);
         g.drawImage(my_gif2,0,0,this);
}This example consists of two files. When run they are visible in a correct way. Now I would like to save it to a disc - I can save one image using BufferedImage but I want to "flatten" two or more images and save it. Any help would be greatly appreciated. I also agree that perhaps my approach is not the right one and would be grateful for any corrections.

If you can draw what you want out to the screen properly, then do the same thing to a BufferedImage's GraphicsContext, once you have the BufferedImage, then use ImageIO to write your image to a file.

Similar Messages

  • Can we save our canvas as a .psd(photoshop) file? as we are saving with .jpg or .png format with the

     
                   I have 2-3 image in my canvas and i want to save it in .psd format means each image will act as a different layer when we will open the saved file in                  photoshop.
                    Thanks & Regards,
                    Parth

    no dear there is not any option as u suggested.
    rightnow i am using my canvas and making the bytearray of it and then I am saving this bytearray  with .jpg/.png format with the JPEG/PNG Encoders. but what it does? It makes a single .jpg file of canvas so if there are 3 images in it than it will save entier canvas as .jpg.
    I want to save each image as different layer and finally the canvas should be save in .psd format show i can open that .psd file in photoshop..
    thanks for the replies
    Thanks and Regards,
    Parth

  • How to export full image in PNG format lying inside a smaller sized rectangle?

    Hi
    In my own created extension for adobe inDesign using CS Extension builder 1.5, I am trying to export a page item lying inside a rectangle frame longer than frame height. Full image is not exported but it gets cropped which is of the rectangle height. I need to get full image exported in PNG format. The item can be text/image/drawing/or group of multiple items lying inside a rectangle frame.
    Sometimes the correct image is exported although the rectangle frame size is smaller than the inside image/item. Following is the code I’m using to export the page item.
    var targetItem:PageItem = pageItem.allPageItems[0];
    targetItem.exportFile(ExportFormat.PNG_FORMAT, targetFile, false);
    Can anybody help me out?
    Thanks and best regards
    Sal

    the answer is at : http://forums.adobe.com/thread/1060138

  • Cannot import still image: jpeg/tiff/png/gif/ai/psd

    Hello all:
    I'm running into a strange error. No matter what size image I try, I cannot seem to import a still image into Adoe Premiere Pro cs4 running on Mac OSX 10.6.2
    The error I receive is a "File Import Error: File Video Dimensions width/height too large."
    I've tried the following to isolate why Premiere is returning this error:
    - importing images at different sizes: 100x200, 1000x2000 etc
    - saving the image as different file formats: jpeg, tiff, gif, png etc
    - importing it as an illustrator file
    - importing it as a Photoshop file
    None of that worked. I'm at my wit's end and I can't seem to find anybody that has experienced this error before.

    Here are some threads to check:
    http://forums.adobe.com/thread/387776
    http://forums.adobe.com/thread/480381
    http://forums.adobe.com/thread/387156
    http://forums.adobe.com/thread/443138
    IIRC, the third one is for the Mac, but might be useful info in all.
    Good luck,
    Hunt
    PS - welcome to the forum

  • "The rasterized image exceeded the maximum bounds for saving to the PNG format"

    Hi everyone, I'm using Illustrator CS4 and encountering the following problem:
    I made a level map in illustrator that exceeds 10000x10000 pixels. When I try to export the image as a PNG, I get the error "Could not complete this operation. The rasterized image exceeded the maximum bounds for saving to the PNG format". I tried saving in JPG and others as well, but got similar errors.
    How can I get around this?

    Here is an interesting discussion: http://bytes.com/topic/php/answers/735556-png-maximum-dimensions
    -- although the dimensions there are way larger than your paltry 10K x 10K. It appearts not to be a limitation of the PNG format, but solely from the software used.
    Here's a question. What on earth do you think you need 10K x 10K PNG files for?

  • Images saved in Photoshop CS6 as PNG or jpeg won't open on Windows computers

    I recently saved an image on Photoshop CS6 as a PNG file so I could send it as an attachment to a client (who uses a Windows computer). They told me the file wouldn't open and instead showed as an "Unknown File".
    I tried opening the file on my Windows computer, as well as a JPEG version to test out, but both came up as "Unknown Files".
    The only way I could transfer the files I saved in Photoshop was to export them as PNG through the 'Preview' application.
    Is there a reason why these normal formats won't open properly?

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

  • How to save a selected word image to image file in open XML in PNG format?

    Hi Everyone,
    I have a very strange problem. I want to extract the image from word using open xml sdk. Here the user selects the image on opened word, and then clicks on any button, so it should extract the same selected image to any predefined location in the PNG format.
    I also tried to do the same thing using Word API, there I am copying the selection of image to clipboard and then getting the image and converting it to bitmap and saving it, but the image resolution is coming very bad. Is there any method through which
    I can save the image to file either by Open XML sdk or Word API using C#.
    Thanks,
    Shahab Abbasi

    Hi Shahab,
    To extract images from word document, please take a look at this thread:
    https://social.msdn.microsoft.com/Forums/office/en-US/e2a795ea-2ab7-401e-b6a8-0576220553f8/openxml-excel-how-to-extract-only-image-files?forum=oxmlsdk
    string fileName = @"C:\test.docx";
    using (WordprocessingDocument document = WordprocessingDocument.Open(fileName, true))
    var e = document.MainDocumentPart.ImageParts.GetEnumerator();
    int picNum = 0;
    while (e.MoveNext())
    picNum++;
    ImagePart imagePart = e.Current;
    Stream stream = imagePart.GetStream();
    long length = stream.Length;
    byte[] byteStream = new byte[length];
    stream.Read(byteStream, 0, (int)length);
    FileStream fstream = new FileStream(@"C:\abc.jpg", FileMode.OpenOrCreate);
    fstream.Write(byteStream, 0, (int)length);
    fstream.Close();
    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.

  • I am trying to use photomerge compose.  I open one standard jpeg image and one image that is my business logo in a png format.  When I select the png image, to extract the logo from it, it appears as all white and will not allow me to select the logo from

    I am trying to use photomerge compose.  I open one standard jpeg image and one image that is my business logo in a png format.  When I select the png image, to extract the logo from it, it appears as all white and will not allow me to select the logo from it.  It has worked in the past but I downloaded the update today and photomerge will not work correctly.  Any ideas?

    hedger,
    How do you expect anyone to help when we don't know a darned thing about the file, abut your setup, exact version of Photoshop and your OS, machine specs, etc.?
    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • I just set up a new computer running Windows 8.1. When I go to my icloud photostream, the pictures are in PNG format NOT JPG. When I open and upload photos from the photostream, the resolution is so low that the image quality is terrible. Help?!?

    I just set up a new computer running Windows 8.1. When I go to my icloud photostream, the pictures are in PNG format NOT JPG. When I open and upload photos from the photostream, the resolution is so low that the image quality is terrible. Help?!?

    Hey Sierra, You can do just what you have stated. My question, what is your "other"? If it is over 1.5 GB you most likely have corrupt files. Doing a Restore to New, Factory restore should correct it. Just make sure you make a full backup of all information on your iPod to your computer before you restore, so you don't lose your stuff, contacts, videos, pictures, non-iTunes music, etc, use the cable and connect with your computer. Then, via cable, connect to your computer, run the Restore to new, don't use your backup. Treat this iPod as if it was your first one ever. When restore is done, set up and add what info you wish to install on this iPod. The music apps etc you purchased should be on your computer, if not you should be able to retrieve purchased apps and music from iTunes. Any music, videos, apps not purchased from iTunes will be lost to you if you do not save them to your computer or the cloud first. When your done, make a current Backup and you should good to go. Hope this helps. Good luck. Cheers.

  • The crawled property of Image width and height - is there a differnce when the image is png format?

    Hi,
    We are indexing file share with images and get the properties of Image Width, Image Height, Image Size (we show it as refiners in SharePoint after make it managed properties). Somehow when the picture is png format - we see only Size but not height and width.
    Is that any setting that should be done in the file share (when i select an image in the windows explorer window i can see all its properties, and it seems that png files do expose the width and height properties
    keren tsur

    Hi  Keren,
    According to your description, my understanding is that when you tried to  crawl file share with images, the ows_ImageWidth and ows_ImageHeight crawled property for PNG  file could not be generated.
    For your issue, I can reproduce your issue in my SharePoint 2013 environment. For a workaround, you can upload the PNG images into SharePoint images Library and they would work fine.
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Using PNG format with max width without clipping top and bottom of image?

    I am using PNG format to preserve the transparency and drop shadow I am trying to incorporate to give the illusion that this slab object is floating above the other layers.  I first tried file>place to position the menu object on edge of header/beginning of content.  Doing that leaves no options to force the image to span the width of whatever screen.  I need that so I've tried using object>fill> and then clicking the max width of the rectangle (which does solve the max width problem), but I am now dealing with a clipping problem of the top and bottom of the image.  The next thing I can think of is to go back to Photoshop and distort the image so it isn't as tall.  I feel there has to be a simpler way to accomplish this that won't also give my image a unnatural look.  Thoughts?  Thanks in advance.

    Thanks, that helps.  I also found that I cropped to much of the canvas.  After increasing the canvas area AND setting to fill all is well now.  I think your suggestion may help with the scrolling affect problem I'm having when using different resolutions. I am going to try to set the size in one dimension (height) so that different resolution screens see the same scroll actions.  Thanks Mylenium!

  • How to save JFrame image as png format?

    hello all..
    i've encountered some problem while i using my Java3D to load my VRML file & save it in png format.
    i've loaded the VRML file in my Java 3D and display it on the JFrame.
    now, i want to save the image as PNG format, but i can't save the image, but just save the background & canvas.
    here's my code:
    Button button = new Button("Save image");
    button.addActionListener( new ActionListener()
    public void actionPerformed(ActionEvent event)
    RenderedImage image = myCreateImage();
    // Write generated image to a file
    try {
    FileDialog fd = new FileDialog(f, "Save as PNG", FileDialog.SAVE);
    fd.show();
    String name= fd.getFile();
    // Save as PNG
    ImageIO.write((RenderedImage)image, "png", new File(name));
    catch (IOException e) {}
    content_pane.add(button, BorderLayout.SOUTH);
    try
    FileReader fr = new FileReader( "TS.java" );
    BufferedReader br = new BufferedReader(fr);
    catch(Exception e) {}
    pack();
    setLocationRelativeTo( null );
    setSize(800, 600);
    setLocation(0, 40);
    setVisible(true);
    setBackground(Color.white);
    public RenderedImage myCreateImage() {
    int width = 800;
    int height = 600;
    // Create a buffered image in which to draw
    BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = bufferedImage.createGraphics();
    g2d.dispose();
    return bufferedImage;
    private void loadFile(String file) {
    int flag = VRML97Loader.LOAD_ALL;
    if(staticLoad)
    flag &= ~VRML97Loader.LOAD_BEHAVIOR_NODES;
    VRML97Loader loader = new VRML97Loader(flag);
    // if the file is a directory, ignore it
    File f = new File(file);
    if(f.exists() && !f.isFile()) {
    System.out.println("Can't load directories specified");
    System.exit(1);
    URL url = null;
    Scene scene = null;
    try {
    if(url != null)
    scene = loader.load(url);
    else
    scene = loader.load("vrml/fish.wrl");
    } catch(Exception e) {
    System.out.println("Exception loading URL:" + e);
    e.printStackTrace();
    System.exit(0);
    urlLabel.setText("File " + file);
    if (scene != null) {
    // get the scene group
    sceneGroup = scene.getSceneGroup();
    sceneGroup.setCapability(BranchGroup.ALLOW_DETACH);
    sceneGroup.setCapability(BranchGroup.ALLOW_BOUNDS_READ);
    sceneGroup.compile();
    // add the scene group to the scene
    examineGroup.addChild(sceneGroup);
    // now that the scene group is "live" we can inquire the bounds
    setViewpoint();
    // setupBackground(scene);
    // setupLighting(scene);

    Your g2d is doring nothing!
    Indent your code.
    class{
       type data1;
       type data2;
       type method(){
           statement;
            clause{
               statement;

  • Does Fireworks support saving/editing images in icon format (.ico)?

    Does Fireworks support saving/editing images in icon format
    (.ico)?

    quote:
    Originally posted by:
    Alan Musselman
    By way of a free extension by John Dunning, yes. Check out
    the Fireworks Developer Center Downloads tab. I think its also PC
    only, but not 100% sure.
    Yes, it's PC only. And it can export a FW file to favicon
    format, but FW can't open .ico files and the command doesn't
    support exporting the various bitdepths and sizes that Windows
    icons support.
    It's also available here:
    http://johndunning.com/fireworks/about/ExportAsFavicon

  • Saving a droplet won't maintain .PNG format...why??

    I created an action that includes changing the format in the Save for the Web feature to .png. When I run the action independently it works fine and saves the file as a .png, when I run this same action as a Droplet it saves the files as .psd. This has worked in previous versions, but I can't figure out why it does not work now. Perhaps something has changed in the File Naming section?
    This fails to maintain the .png format in both the Mac and PC versions.

    What version of photoshop are you using?
    Can you post a screenshot of the action and settings your using in the create droplet dialog?

Maybe you are looking for

  • CS3 with Codec MainConcept DVCPro HD CODEC v7 7 0 23862 rar - can't import AVCHD (m2ts files)

    Hi, I have a Panasonic hdc-sd9 and just looking for a programm with which I can import the AVCHD (m2ts files). I saw here( http://www.videoaktiv.de/200805171688/News/Camcorder/Panasonic-Broadcast-AVCHD-goes-profes sional.html ) that Adobe Premiere Pr

  • Is there any way to display pictures in a report program...

    Is there a way to display some pictures say background or foreground pics in a report program ?? Kindly help me in this. Thanks in advance, Krishna, 9986023724

  • Suppress Printing

    How could I suppress exporting report if no records are loaded using sdk? If setting options in report to suppress i get blank page in pdf when exporting, is there a way to evaluate if fields have data or not? Is there a way to retrieve sql statement

  • PreEl 8 and Windows 7 64 bit...

    Hi: Has any forum member had any experience with running PreEl 8 on the Windows 7 64 bit OS? I'm currently using Vista Home Premium (32 bit) but am growing tired of it... no problems with PreEl 8, but Vista is growing long in the tooth... I realize t

  • Why is my iphone  not doing anything?

    So I tried to download ios7 to my iphone 4, and it began. When i looked at my phone agian the screen went dark. Theres no images or signs that the phone is working, and i cant restart it or anything. this has happened for almost 8 hours, most of whic