Picking up image drawan on panel into image object and saving itto file.

hi dear friends,
please help me out , My problem is:
On challan generation screen we want to make provision for signeture.So for that purpose we have placed panel inside the frame where user can do the signeture.
Signeture drawing is working .But now the next step is that i want to store it in a file(I mean to say whatever drawn on panel) so that that file can be saved in database and later on it can be retrived when ever required.
will be thankful if anyone helps me.
waiting for replays.

try to use following code :
BufferedImage im = new BufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_INT_RGB);          
                         Graphics2D g2 = im.createGraphics();
                         //you may want to set background color, etc...     
                         comp.paint(g2);          
                         try          
                              GIFEncoder gif = new GIFEncoder(im);
                              gif.Write(new FileOutputStream(file));
                         catch(Exception e)          
GifEncoder can be obtained from net. if u want i can mail u also.

Similar Messages

  • HT2509 I have installed a font from the internet into Font Book and saved it in my Fonts folder under my user library. How can I make it available in Word to type a document?

    I have installed a font from the internet into Font Book and saved it in my Fonts folder under my user library. How can I make it available in Word to type a document?

    Font Management in OS X

  • Changing image orientation while saving to file

    I get a Base64Encoded image string (GIF format) from an external system. While reading the byte array and saving the image to file, the image gets saved in landscape orientation.
    The code snippet is below.
    String image = "R0lGODdhCAcgA=";
    Base64Coder decoder = new Base64Coder();
    byte [] decodeBytes = decoder.decode(image.getBytes());
    ByteArrayInputStream stream = new ByteArrayInputStream(pngArray);
    BufferedImage bImage = ImageIO.read(stream);
    File label = new File("C:/labels/test.gif");
    ImageIO.write(bImage, "gif", label);
    I want to save the image in portrait orientation. Is there a way to do that?

    Looks like ImageIO doesn't support that but third party libraries do.
    See if you can use the solution in this thread:
    java - Is javax.imageio.ImageIO broken? It imports some images as rotated - Stack Overflow

  • Unable to read big files into string object  and java.lang.OutOfMemory Prob

    Hi All,
    I have an application that uses applet and servlet communication. On the client side I am reading an large xml file of 12MB size (using JFileChooser) and converting the file to an string object using below code. But I am getting java.lang.OutOfMemory on the client side . But the same below code works fine for small xml files which are less than 4MB sizes:
    BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF8"), 1024*12);
    String s, s2 = new String();
    while((s = in.readLine())!= null)
         s2 += s + "\n";
    I even tried below code but still java.lang.OutOfMemory is coming:
    while (true)
         int i = in.read();
         if (i == -1)
              break;
         sb.append(i);
    Please let me know what am I doing wrong here ...
    Thanks & Regards,
    Sony.

    Using a String is bad for the following reason:
    When you initially create the String, it has a certain memory size (allocated length if you will). As you keep appending to this String, then memory reallocation will occur over and over, slowing your program down dramatically (ive seen with a 16k x 8 Char file taking 30 secs to read into memory using Strings in this way)
    A Better way would be if you knew the number of characters in the XML file (Using some File size method for example) Then you can use a StringBuffer, which will pre allocate enough space (or try to, it may just be that you cannot create a string as large as you need). You can use toString() method to get the resultant in a String Object (the extra allocated space at the end of the Buffer will be removed)
    StringBuffer strBuf = new StringBuffer(xxxx);
    Where xx is the length (int). Assuming that you are only allowed to enter an int to the constructor then (platform depedant) an int is 2^31 at maximum (or whatever) which allows 2.14e9 characters, therefore an xml file being totally filed would allow a size of ~2048 MB to be read in.
    Try it and see.

  • Raw Images opened and saved as TIFF of PSD in photoshop not added to LR library

    Images opening from LR to PS6 are opened as CR2 files (canon) and then saved in PS - the resulting saved images are PSD files. These files are not added to the LR catalog without re-importing them. This behavior is different than it was in CS5 - in CS5 they are opened as PSD and immediately added to the LR catalog. I want the same bahavior in CS6. In LR I have set preferences to open files as PSD but they are not PSD until they are saved in PS.

    The behaviour you are now seeing when using CS6 is normal when Lightroom and Photoshop are in sync in respect of the ACR level, i.e. the derivative PSD/TIFF is NOT created until you hit Save in PS. When the ACR levels are not in sync (i.e. the PS version is lower than the LR version, as is the case using LR4 and CS5) the "ACR Mis-match" dialog appears (though you may have ticked the "Do Not Show Me Again" box after selecting "Render Using Lightroom") and in that situation the derivative file is created by Lightroom, so you see it appear in LR before it is opened into PS. The fact that the filename that you see in CS6 shows the CR2 extension is not an issue (PS always retains the raw file's full name until it is saved as a derivative file....try opening a raw file directly into CS5/CS6 from outside Lightroom and you'll see), and it will change as soon as you select Save, at which point you should also see the PSD/TIFF appear in Lightroom.
    So the only question is, why are you not seeing it? Can you confirm that when you are done in PS that you are selecting "Save" and not "Save As"? And that Lightroom is still running when you do that? And what source are you working from: Folder, Collection, Smart Collection? When you import the PSD, is "Do not import suspected duplicates" cheched or unchecked?

  • Two Simultaneous USB Camera Image Acquisition and Saving

    Hello everyone,
    Recently my friends and I have begun a project which requires the simultaneous acquisition of images from two independent USB cameras. Throughout our project research we have encountered many difficulties. The major problem appears to be how to successfully interface two USB cameras and properly save the image to a median for further processing down the road.
    Our first attempted at this was with the USB IMAQ drivers. Unfortunately, to our surprise, it does not support two independent and simultaneous camera acquisitions. To combat this problem we implemented a crude loop of closing a camera reference, then opening the other, acquiring an image, then closing, etc... This did provide us with functionality but was very inefficient, resulting insufficient acquisition speeds.
    Afterwards we began looking at other ways of capturing and writing the image, which are listed below.
    Various Acquisition Interfaces / Strategies
    USB IMAQ Driver - USB interfacing kit available for public download, (not officially supported by NI) zone.ni.com/devzone/cda/epd/p/id/5030
    Status - Abandoned because of the lack of dual web camera support
    Avicap32.dll - Windows 32 DLL responsible for all web camera communication, and other media devices.
    Status - Currently acquired two streams of video on the front panel but with no way of saving the images
    Directx - The core Windows technology that drives high-speed multimedia on a PC.
    Status - Currently researching.
    .NET - Microsoft .NET framework, possibly a valid interface to a video stream.
    Status - No development until further progress.
    We are still currently developing the Avicap32.dll code but the major bottleneck is the learning curve on the property nodes, library calling nodes, .NET and other references. So far it’s been a tedious effort of trying to understand example code and piece them together. As a former programmer of C I know this is not the proper way of writing code web I can’t seem to grasp how these functions work. (Property nodes, library calling nodes, .NET and other references). Learning this may allow us the knowledge to code a proper system. Does anyone know any good tutorials or learning material for such functions? So far my research has come up empty handed.
    We are currently working with these interfaces and other reference examples on the NI site. Unfortunately we cannot seem to properly integrate the code for our system. Does anyone know if this setup is even possible? Also, if anyone has any experience with similar systems and can offer advice, code snippets, or any other assistance it would be greatly appreciated.
    Our current projects will be posted below if you have any suggestions. (More will be added when I get to my desktop tomorrow)
    Two Camera Avicap32.dll - Currently stuck on how to save the image, various tweaks have gotten us stuck at this point ( will have another Avicap32.dll implementation posted tomorrow)
    USB Capture Example - This USB capture VI was an example that immediate had problems. We used it as a baseline for crude open-close camera image grabbing system. (Will also be posted tomorrow)
    Thanks for any help, it's much appreciated.
    Taylor S. Amarel
    Thanks,
    Taylor S. Amarel
    Learning is living.
    Co-Founder and CEO of http://3dprintingmodel.com/
    "If we did all the things we are capable of, we would literally astound ourselves."
    -Thomas Edison
    Attachments:
    Two Camera Avicap32.dll.zip ‏84 KB
    USB Capture Example.zip ‏17 KB

    Thanks for the information but that's not exactly what I'm looking for. I've been to that URL and read the information before. I don't mean to disparage you help but I'm looking for ways that I can successfully implement a functional system, not information on an unfunctional method. Maybe I was unclear before, I'm looking for any advice, knowledge or help on how to make this system properly work.
    Thanks, have a great day.
    Taylor S. Amarel 
    Learning is living.
    Co-Founder and CEO of http://3dprintingmodel.com/
    "If we did all the things we are capable of, we would literally astound ourselves."
    -Thomas Edison

  • [WPSL]how to rotate system.windows.control.image object and save it to iso storage.

    i capturing image using Microsoft.Device.PhotoCamera. it is working fine but when i save it into  phone,it's orientation change to 90 degree.i need to rotate that image to proper orientation.....thanks in advance.

    My advice is to use blend first. You rotate using the UI. Once you see the results from Blend you can then start coding
    it by hand if you wish to
    I sale myself ONLY half CNY!

  • Image uploading and saving to database

    hi ,
               I am developing application for summer placement . i want to upload image with candidate'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  candidate's details.
    Kavita

    Hi kavita,
                   In Webdynpro u r using attribute of type Resource ,which is binded to FileUpload UI element. From this attribute, u get file in Input stream format which can be converted into byte array like this
    byte fileData[] = null;
          try{
                InputStream fileIs = wdContext.currentFile().getFileData().read(false);
                ByteArrayOutputStream bOut = new ByteArrayOutputStream();
                int length;
                byte[] part = new byte[10 * 1024];
                while ((length = fileIs.read(part)) != -1) {
                      bOut.write(part, 0, length);
                fileIs.close();
                fileData = bOut.toByteArray();
                bOut.close();
          } catch (Exception e) {
                wdComponentAPI.getMessageManager().reportSuccess(e.toString());
    In webservice u can take a the byte array as input parameter where the uploaded file will be passed as byte array .
    In DB u can store it as BLOB .
    in case of any other doubt u can revert back to me.
    regards
    Sumit

  • Incorrect image size and low quality file (Photoshop CC trial ver. on Macbook Pro Retina)

    At first, I set 500x500 size
    but in workplace, it show smaller than 500x500 (maybe 250x250?)
    I check on "image > image size" it still show me 500x500 pixels
    Save for web
    After that, i got a 500x500 file but It resize from smaller to 500x500 , so... i got a low quality file.
    what's wrong?
    (sorry for bad english skill but i really want your help)
    Ps. it also incorrect when i set resolution as 300dpi

    Pixel is not a measurement unit of length per se.
    If a screen has more pixels per unit of length an image (when displayed as one image pixel per one screen pixel) would appear smaller than on a screen with lower resolution.
    To make sure could you please post an image that is 500px x 500px (according to Image > Image Size) but seems to be too small to you?

  • Image editing and saving it

    Hello all,
    i am an iPhone Developer,
    i want to edit an image using another image you can say that i want to paste a smaller image(in size)
    on to the larger one and then want to save this image and wants a single image as a result.
    i did the code for imposing image on to the first one and even code for saving image to the photo gallery but i am getting stuck with one issue, that is:
    while saving the image we have to give the image reference as the first parameter to the following method..
    UIImageWriteToSavedPhotosAlbum( UIImageView.image, self, @selector(imageSavedToPhotosAlbum: didFinishSavingWithError: contextInfo, nil);
    and the problem i am facing is
    there is one UIImageView object for the UIView and while using UIImageView.image i get the first image not the mixed image that i want.
    please help me for getting the desired image.
    thanks

    If you already posted on the developer forums, why didn't you say so?
    I pointed you to the developer forums, because I assumed that you didn't know the right place where to post developer questions (a user-to-user and iPhone usage discussion forum is not the place for programming questions).

  • Why does the Amount slider on the Detail Panel reset to 0 when saving the file as a Smart Object?

    Whenever I open a Smart Object PSD file to adjust previous settings in RAW, I have noticed that the Amount slider in the Detail panel has reset to 0. Does this reduce the files sharpening? Is this a normal behavior? Can this be prevented?
    I use a Mac running 10.6.8 and Photoshop CS6, version 13.0.5 x 64.

    This behavior happens only on Mac desktop computer, not on my Mac laptop running the same CS6.
    After I've edited an ACR file (including sharpening in the Detail panel), I change the file into a PSD Smart Object to complete my edit by clicking on "Open Object". I immediately notice this PSD file is not sharp. If I click on the bottom right of the image icon to return to the RAW file, I find the Amount slider in the Detail Panel has changed from the sharpening amount I gave it, to 0.
    If I do the exact same thing on my laptop (running a duplicate of the same Photoshop CS6), this behaviour does not happen. The image remains sharp as a PSD file, and if I check by returning to ACR, the Amount slider has maintained its setting.
    Anything more you need?

  • Save an Image object into a XML text document

    ello:
    I have a problem with saving an image. I need to encapsulate it into two XML tags:
    <Image> xxxxxx </Image>
    The "xxxx" must be a String that represents my Image object.
    In J2ME I haven't serialization, and all the examples about "manual serialization" works with primitive types :(
    I've already read that I can do .getRGB() over my Image object, and obtain an array of int, wich represent each pixel. Ok, I can transform the array into a String, and write it in my XML text document, but later: how I obtain my array from that String?
    Thak you very much

    private Image img;
    byte rgb[] = null;
    private rgbLength; // get lenth of your string
    rgb = new byte(rgbLength);
    rgb = ... //load data from string to this array
    img = createRGBImage(rgb, int width, int height, false) ;You must know length of your string and must encapsulate in to XML width and height of this image;

  • Illustrator hangs when saving .ai files with linked or embedded images

    Hi,
    Currently I have a huge problem with Adobe Illustrator. When I place an image file inside an Illustrator document, the program freezes for about 45 seconds when saving. In the beginning I though it was just because my image file was too big, but that wasn't the case.
    To test what's going on I created a new document, drew a few lines and saved. No problem, Illustrator saved immediately. Then I placed a bigger image and suddenly Illustrator hang when saving. I repeated this with a very small GIF of just a few kB and again, Illustrator hang for nearly a minute when saving the image. I tried embedding the image instead of linking it, but I still got the same results.
    Then I turned of the visibility of the image object by clicking on the little eye symbol in front of the image object and suddenly Illustrator was able to save quickly again. The next thing I wanted to try was turning off compression and PDF compatibility, but then I noticed that Illustrator is actually hanging BEFORE writing the file to disk. When I hit "Save as" Illustrator asked me where to save the new file and then after clicking "Save" it hang (showing "(Not Responding)" in the title bar). About 45 seconds later the save options dialog came up and when I clicked "OK" it saved the file immediately.
    Does anybody know what the problem might be? I'm using Illustrator CS5 on Windows 7 x64. The computer is a notebook with 8GB RAM and a switchable graphics card. I tried this on both the integrated Intel graphics unit and on the much more powerful AMD chip. The hard driver I'm saving to is the local hard drive (no network drive etc.).
    This is a more or less fresh installation (I haven't used Illustrator before on this notebook) and I can't remember that I had the same problem on my workstation where I used it inside a virtual machine (which doesn't exist anymore).

    Yeah, I know that changing the mode results in different colors. I just switched back and forth to check out what's going on.
    For CMYK I'm using ECI profiles which are common in Europe and for RGB the normal Adobe RGB 1998 profile. The profiles are synced between all Creative Suite products. I tried sRGB and some of the default profiles which shipped with CS5 but it produces the same result. I also deleted my whole Illustrator profile but without success.
    My graphics card doesn't have any updates. But it would be very unlikely anyway that both drivers for both cards had the same issue. If it has something to do with my graphics cards it's more likely the switchable graphics in general.

  • Load jpg in image object

    Hi, i'm trying to create an image object from a jpg file:
    public static void main(String[] args)
    Image img;
    Toolkit t;
    t = Toolkit.getDefaultToolkit();
    img = t.getImage("C:\\Documents and Settings\\m.lipreri\\Desktop\\ciao.jpg");
    System.out.println("img: "+img.toString());
    Frame f = new Frame("Es1_Im");
    ImageFrame IM = new ImageFrame(f,img);
    IM.addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e){
    System.exit(0);
    IM.setSize(500,400);
    IM.setVisible(true);
    class ImageFrame extends Frame{
    Frame f;
    Image im;
    //costruttore
    ImageFrame(Frame f,Image im){
    this.f = f;
    this.im = im;
    public void paint(Graphics g){
    g.drawImage(im,0,0,this);
    }but this code doesn't show me anithing in the applet, the image path is right, i've tried to past the path in my browser and i can see the image.
    thnx

    Images get loaded asynchronously, so the image
    probably isn't loaded completely when you try to
    display it. See java.awt.MediaTracker or use
    javax.swing.ImageIcon for loading.I could be wrong, but isn't that the ancient way of doing it? I haven't used MediaTracker in ages. Just use ImageIcon. It's the easist way I know to work with images.

  • Changing colors in an Image object

    I have an Image objects and want all the red pixels in it changed to blue during runtime.
    How can I do that?

    ImageIcon oldImage = new ImageIcon("C:\\duke\\t1.gif");
    ImageProducer producer = new FilteredImageSource(oldImage.getImage().getSource(),new MyFilter());
    ImageIcon newImage = new ImageIcon(Toolkit.getDefaultToolkit().createImage(producer));
    JLabel jl = new JLabel(newImage);
    // Image filter
    class MyFilter extends RGBImageFilter{
      public int filterRGB(int x, int y, int rgb) {
        int alpha = (rgb >> 24) & 0xff;
        int red = (rgb >> 16) & 0xff;
        int green = (rgb >> 8) & 0xff;
        int blue = rgb & 0xff + red;
        if (blue>255) blue=255;
        red=0;
        return alpha << 24 | red << 16 | green << 8 | blue << 0;
    }

Maybe you are looking for