Sun.awt.image.ToolkitImage

Hi
I'm integrating with a 3rd party package which delivers various images.
These come in different objects, mostly BASE64DecoderStream and BufferedImage. But, GIF files are delivered as a ToolkitImage object.
For the BufferedImage I do something like
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ImageIO.write(image, "JPG", stream);and puts it in DB. I just can't figure out a way to do the same for ToolkitImage.
My questions are:
1. Is there a way to convert/cast the ToolkitImage so i can format/encode it and put it in DB, similar to the example above?
2. Where is the API documentation for the internal classes in package "sun.awt.image"?
Hope you experts can help me out here :)

> Didn't know it could be casted to an Image.
Do you know of any documentation on sun.awt.image in general?
Why Developers Should Not Write Programs That Call 'sun' Packages
The classes that Sun includes with the Java 2 SDK, Standard Edition, fall into package groups java.*, javax.*, org.* and sun.*. All but the sun.* packages are a standard part of the Java platform and will be supported into the future. In general, packages such as sun.*, that are outside of the Java platform, can be different across OS platforms (Solaris, Windows, Linux, Macintosh, etc.) and can change at any time without notice with SDK versions (1.2, 1.2.1, 1.2.3, etc). Programs that contain direct calls to the sun.* packages are not 100% Pure Java. In other words:
The java.*, javax.* and org.* packages documented in the Java 2 Platform Standard Edition API Specification make up the official, supported, public interface.
If a Java program directly calls only API in these packages, it will operate on all Java-compatible platforms, regardless of the underlying OS platform.
The sun.* packages are not part of the supported, public interface.
A Java program that directly calls into sun.* packages is not guaranteed to work on all Java-compatible platforms. In fact, such a program is not guaranteed to work even in future versions on the same platform.
For these reasons, there is no documentation available for the sun.* classes. Platform-independence is one of the great advantages of developing in the Java programming language. Furthermore, Sun and our licensees of Java technology are committed to maintaining backward compatibility of the APIs for future versions of the Java platform. (Except for code that relies on serious bugs that we later fix.) This means that once your program is written, the class files will work in future releases.
Each company that implements the Java platform will do so in their own private way. The classes in sun.* are present in the SDK to support the Sun implementation of the Java platform: the sun.* classes are what make the Java platform classes work "under the covers" for the Sun Java 2 SDK. These classes will not in general be present on another vendor's Java platform. If your Java program asks for a class "sun.package.Foo" by name, it may fail with ClassNotFoundError, and you will have lost a major advantage of developing in Java.
Technically, nothing prevents your program from calling into sun.* by name. From one release to another, these classes may be removed, or they may be moved from one package to another, and it's fairly likely that their interface (method names and signatures) will change. (From the Sun point of view, since we are committed to maintaining the Java platform, we need to be able to change sun.* to refine and enhance the platform.) In this case, even if you are willing to run only on the Sun implementation, you run the risk of a new version of the implementation breaking your program.
In general, writing java programs that rely on sun.* is risky: they are not portable, and are not supported.
~

Similar Messages

  • Java.io.NotSerializableException: sun.awt.image.BufferedImageGraphics2D

    Hi all!
    This problem is in relation to a very complex bean for data visualization which is jarred and bridged as an activex control.
    I am able to create the activex control and embed it in a vb form. But when I try to run the application in vb I get the following message and the application does not start.
    java.io.NotSerializableException: sun.awt.image.BufferedImageGraphics2D The bean has not used the class mentioned above anywhere. It uses the
    Image
    class though. I have used other beans, which use the same drawing techniques as the bean in question, as activex controls, with no errors.
    What could be the problem?
    tia
    Shailesh
    PS: the actual error dump is 1 page long I can send it by email on request.

    Hello,
    Have you implemented the Serializable Interface? I usually receive that error when I forgot to implement that interface. It is mandatory for a JavaBean to implement this interface.
    As an example:
    import java.io.Serializable;
    public class SimpleBean implements Serializable
    I hope it helps.
    Antonio Castro

  • Where is sun.awt.image.Image in Java5?

    Hello,
    I'm trying to compile a package using Java 5, which was before compiled with 1.4. I geth the error "sun.awt.image.Image cannot be resolved or is not a valid superclass".
    I found that class in 1.4.2, but not in 1.5. Is there an substitution for that?
    Regards,
    Kai

    Look in:
    java.awt.Image and java.awt.image for your needs and remember the sun.* packages are not guarenteed to be supported or be the same from version to version.

  • Where to download  "sun.awt.image.codec.JPEGImageDecoderImpl"/Windows

    Hello,
    I bought some Java API. These API uses com/sun/image/codec/jpeg/JPEGCodec.
    I found these clases in src.zip in java install directory.
    Then, this code has a source line
    "import sun.awt.image.codec.JPEGImageDecoderImpl;"
    Where can I find/downlad this class?
    (I work on Windows platform)

    This class is in rt.jar package
    which is in ur jre directory/lib
    Hope u got it!!
    Pradhip

  • OutOfMemory error in java.awt.image.DataBufferInt. init

    We have an applet application that performs Print Preview of the images in the canvas. The images are like a network of entities (it has pictures of the entities involve (let's say Person) and how it links to other entities). We are using IE to launch the applet.
    We set min heap space to 128MB, JVM max heap space to 256MB, java plugin max heap space to 256MB using the Control Panel > Java.
    When the canvas width is about 54860 and height is 1644 and perform Print Preview, it thows an OutOfMemoryError in java.awt.image.DataBufferInt.<int>, hence, the Print Preview page is not shown. The complete stack trace (and logs) is as follows:
    Width: 54860 H: 1644
    Max heap: 254 # using Runtime.getRuntime().maxMemory()
    javaplugin.maxHeapSize: 256M # using System.getProperties("javaplugin.maxHeapSize")
    n page x n page : 1x1
    Exception in thread "AWT-EventQueue-2" java.lang.OutOfMemoryError: Java heap space
         at java.awt.image.DataBufferInt.<init>(Unknown Source)
         at java.awt.image.Raster.createPackedRaster(Unknown Source)
         at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
         at java.awt.image.BufferedImage.<init>(Unknown Source)
         at com.azeus.gdi.chart.GDIChart.preparePreview(GDIChart.java:731)
         at com.azeus.gdi.chart.GDIChart.getPreview(GDIChart.java:893)
         at com.azeus.gdi.ui.GDIUserInterface.printPreviewOp(GDIUserInterface.java:1526)
         at com.azeus.gdi.ui.GDIUserInterface$21.actionPerformed(GDIUserInterface.java:1438)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Drilling down the cause of the problem. The OutOfMemory occurred in the constructor of DataBufferInt when it tried to create an int array:
    public DataBufferInt(int size) {
    super(STABLE, TYPE_INT, size);
    data = new int[size]; # this part produce out of memory error when size = width X height
    bankdata = new int[1][];
    bankdata[0] = data;
    The OutOfMemory error occurred when size is width * height (54860 X 1644) which is 90,189,840 bytes (~86MB).
    I can replicate the OutOfMemory error when initiating an int array using a test class when it uses the default max heap space but if I increase the heap space to 256MB, it cannot be replicated in the test class.
    Using a smaller width and height with product not exceeding 64MB, the applet can perform Print Preview successfully.
    Given this, I think the java applet is not using the value assigned in javaplugin.maxHeapSize to set the max heap space, hence, it still uses the default max heap size and throws OutOfMemory in int array when size exceeds the default max heap space which is 64MB.
    For additional information, below is some of the java properties (when press S in java applet console):
    browser = sun.plugin
    browser.vendor = Sun Microsystems, Inc.
    browser.version = 1.1
    java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
    java.awt.printerjob = sun.awt.windows.WPrinterJob
    java.class.path = C:\PROGRA~1\Java\jre6\classes
    java.class.version = 50.0
    java.class.version.applet = true
    java.runtime.name = Java(TM) SE Runtime Environment
    java.runtime.version = 1.6.0_17-b04
    java.specification.version = 1.6
    java.vendor.applet = true
    java.version = 1.6.0_17
    java.version.applet = true
    javaplugin.maxHeapSpace = 256M
    javaplugin.nodotversion = 160_17
    javaplugin.version = 1.6.0_17
    javaplugin.vm.options = -Xms128M -Djavaplugin.maxHeapSpace=256M -Xmx256m -Xms128M
    javawebstart.version = javaws-1.6.0_17
    Kindly advise if this is a bug in JRE or wrong setting. If wrong setting, please advise on the proper way to set the heap space to prevent OutOfMemory in initializing int array.
    Thanks a lot.
    Edited by: rei_xanther on Jun 28, 2010 12:01 AM
    Edited by: rei_xanther on Jun 28, 2010 12:37 AM

    rei_xanther wrote:
    ..But the maximum value of the int data type is 2,147,483,647. That is the maximum positive integer value that can be stored in (the 4 bytes of) a signed int, but..
    ..The value that I passed in the int array size is only 90,189,840...its only connection with RAM is that each int requires 4 bytes of memory to hold it.
    new int[size] -- size is 90,189,840Sure. So the number of bytes required to hold those 90,189,840 ints is 360,759,360.
    I assumed that one element in the int array is 1 byte. ..Your assumption is wrong. How could it be possible to store 32 bits (4 bytes) in 8 bits (1 byte)? (a)
    a) Short of some clever compression algorithm applied to the data.

  • Could not initialize class sun.awt.X11.XToolkit

    hi all
    String fileName = "c:/test/one.jpg";
    Image imgg = Toolkit.getDefaultToolkit().getImage(fileName);
         ImageIcon img = new ImageIcon(imgg);
         imgDim = ""+img.getIconHeight();
    when i run this code in linux machine am getting the error Could not initialize class sun.awt.X11.XToolkit....but its runnig on windows machine.. is there anything wrong wiht my code........pl help me any1 out of dis

    here http://rapid-i.com/rapidforum/index.php?topic=366.0
    they talk about adding to the JVM options a "-Djava.awt.headless=true"

  • Question : Save AWT Image Class to File..

    I Have a Question.. @.@a
    I'm doing AWT transform now..
    Well...
    I have a problem..
    I want to save AWT Image class to file..
    But.. I don't now that..
    Input Image Class same below..
    Image imageContent = (Image)attachment.getContent();
    How does it save imageContent Image class to file..?

    I had the same problem... convert it to a BufferedImage (http://forum.java.sun.com/thread.jspa?threadID=665744&tstart=15), then use javax.imageio.ImageIO.write to save it to a file.

  • Exception : sun.awt.windows.WImage

    i am new on serializable
    i am going to serialize a set of java.awt.Image
    but Exception occurs (sun.awt.windows.WImage)
    can any one tell me how to solve the problem??

    Images aren't serializable, but javax.swing.ImageIcons are. If you can instantiate your images as ImageIcons (see the constructors for ImageIcon) before you serialize them, after you de-serialize them, you can extract the images represented by them using ImageIcon's getImage() method.

  • Useless code in java.awt.image.SampleModel.java?

    Hey there,
    i just looked up the sourcecode of java.awt.image.SampleModel.java in JDK 6
    I discovered two issues i'd like to discuss.
    1) on lines 736 to 739 this code is stated:
    if (iArray != null)
    pixels = iArray;
    else
    pixels = new int[numBands * w * h];
    I asked myself, why does this code exist? while the getPixels() method is overwritten twice by double[] getPixels() and float[] getPixels, it is impossible to reach the part of the java code that initializes the pixels-array. One could only step into that line if "null" is given for the i/d/fArray-parameter. but if one would do so, the Java parser couldn't determine, which method is to use. so this part of code is just useless IMHO.
    the java developers could get a little more performance out of this method if the if statement would be cut out - especially when reading a lot of very small rasters
    or, on the other hand, they could replace this piece of code by an explicit bounds check.
    When somebody touches this code, i would appreciate it if the errormessage "index out of bounds!" could be rewritten to be a little more verbose, like: Index out of bounds(x=123; y=456, maxX=100, maxY=400)!(numbers are just examples)
    I hope i didn't miss something very basic and could help improving this class a little bit.
    2) the local variable Offset(line 734) is coded against code conventions which say, variables shall start with a lowercase letter. Offset obviously doesn't fit that convention.
    best regards
    kdot

    One could only step into that line if "null" is given for the i/d/fArray-parameter. but if one would do so, the Java parser couldn't determine, which method is to use. so this part of code is just useless IMHO. You can have
    sampleModel.getPixels(x,y,w,h,(int[]) null, dataBuffer);No ambiguity on which method to use.
    the local variable Offset(line 734) is coded against code conventions which say, variables shall start with a lowercase letter. Offset obviously doesn't fit that convention. You're correct, offset is against coding conventions. So are many other examples scattered throughout the jdk source code. For example, Hashtable should be called HashTable. In some cases the coding conventions might not have been established when the original code was written. In other cases it might have been human error. In yet other cases the conventions were probably ignored. The person who wrote the SampleModel class did so some 10+ years ago (Java 1.2). Who knows what he/she was thinking at the time, and in all honesty - does it really matter in this case?
    Did you know there are some classes that declare unused local variables (ahem ColorConvertOp)? Some also have unused imports ( *** cough *** BufferedImage *** cough *** ). In essence, the jdk source code is not the epidemy of code correctness. But it's still pretty good.

  • How can I create a java.awt.Image from ...

    Hi all,
    How can I create a java.awt.Image from a drawing on a JPanel?
    Thanks.

    JPanel p;
    BufferedImage image =
        new BufferedImage(p.getWidth(), p.getHeight, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = image.createGraphics();
    p.paint(g);
    g.dispose();

  • How to save a awt image in SVG file?

    hi all,
    Can anyone please tell me how to store a awt Image to an SVG file....
    For this i tried to change the awt image to outputstream, But I couldnt do that.
    As i am using some licensed software if i able to convert the awt image to output stream then my work will be done... can u please help me out in this..
    regards
    Mohanraj.K
    chennai

    javax.imageio API allows you to write/create a jpeg/png/bmp/wbmp ... image format. I don't think there's support for svg. you'll have to look for some third party plugin.
    Thanks,
    Kannan

  • Sun.awt.X11.XToolkit processException

    In my application, I'm embedding a Java AWT Frame into a Qt widget and for that I'm using "sun.awt.X11.XEmbeddedFrame.java" class.
    I pass the "Window Id" of the QWidget to XEmbeddedFrame which then displays itself into the QWidget.
    The embedding works fine, i.e., the Java frame gets displayed into the QWidget but when I try to close the QWidget (by clicking on the 'x' button on the QWidget window), I get the following exception:
    sun.awt.X11.XToolkit processException
    WARNING: Exception on Toolkit thread
    sun.awt.X11.XException: Cannot write XdndProxy property
    at sun.awt.X11.XDnDDropTargetProtocol.registerEmbedderDropSite(Unknown Source)
    at sun.awt.X11.XDropTargetRegistry.updateEmbedderDropSite(Unknown Source)
    at sun.awt.X11.XDropTargetEventProcessor.doProcessEvent(Unknown Source)
    at sun.awt.X11.XDropTargetEventProcessor.processEvent(Unknown Source)
    at sun.awt.X11.XToolkit.run(Unknown Source)
    at sun.awt.X11.XToolkit.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Any ideas on what might be causing this exception and how to handle it?
    Do I need to write my own error handler? But XToolkit.XErrorHandler interface is not public. Is there any other way?
    Thanks!

    Well The issue was somewhere else due to it reading too much of data. It ran but my program is very slow (approx 2-3 hrs).
    I am worried about the speed...
    is it because of the large amount of data.. 23,355,459 records..?? or there could be some issue in programming probably memory leak etc..??
    -> reads db
    -> for each record set
    -> perform different operation/ writes to file

  • Sun.awt.* package

    hello
    i have a problem in finding sun.awt.* package on the net if anybody has it can you please send it to me . and also with instructions like how to set the class path and is it needed put the package in jdk or its ok to put it out side jsdk. please send me asap.
    as iam developing my own filechooser class thats why i need this package to compile my class.
    thank you
    regards

    hello nobody there to help me with my problem.
    actually i have overrided the class Jfilechooser using only basic packages with importing sun.awt.shell.* package but iam facing this errors can you please help me out of this problem.
    FileChooser.java:4: package sun.awt.shell does not exist
    import sun.awt.shell.*;
    ^
    FileChooser.java:162: cannot resolve symbol
    symbol : class ShellFolder
    location: class FileChooser
    ShellFolder getShellFolder(File f) {
    ^
    FileChooser.java:88: cannot resolve symbol
    symbol : class ShellFolder
    location: class FileChooser
    if (!(f instanceof ShellFolder)) {
    ^
    FileChooser.java:93: cannot resolve symbol
    symbol : variable ShellFolder
    location: class FileChooser
    f = ShellFolder.getShellFolder(f);
    ^
    FileChooser.java:130: cannot resolve symbol
    symbol : class ShellFolder
    location: class FileChooser
    if (f instanceof ShellFolder) {
    ^
    FileChooser.java:131: cannot resolve symbol
    symbol : class ShellFolder
    location: class FileChooser
    return ((ShellFolder)f).isFileSystem();
    ^
    FileChooser.java:140: cannot resolve symbol
    symbol : class ShellFolder
    location: class FileChooser
    ShellFolder sf = getShellFolder(dir);
    ^
    FileChooser.java:163: cannot resolve symbol
    symbol : class ShellFolder
    location: class FileChooser
    if (!(f instanceof ShellFolder)
    ^
    FileChooser.java:170: cannot resolve symbol
    symbol : variable ShellFolder
    location: class FileChooser
    return ShellFolder.getShellFolder(f);
    ^
    FileChooser.java:221: cannot resolve symbol
    symbol : variable ShellFolder
    location: class FileChooser
    return ShellFolder.isFileSystemRoot(dir);
    ^
    FileChooser.java:226: cannot resolve symbol
    symbol : variable ShellFolder
    location: class FileChooser
    File f = (File)ShellFolder.get("fileChooserDefaultFolder");
    thanks in advance
    regards

  • Strange references from "sun.awt.X11.InputMethod"

    We profiled our software and found obscure references for panels that have been closed, but can not be garbaged collected because there is a reference from "sun.awt.X11.InputMethod".
    It seems that it has something to do with the clipboard / Klipper of Linux, as the reference is sometimes solved when marking and copying text. Anyone had this error too and is this a bug in Java, or how can we fix that issue? We have very huge panels and are getting memory problems if they are not deleted correctly or too late. Has anyone more infos of the cause and what can be done?
    Please help.

    Similar problem I solved with update driver printer.
    Bya

  • AccessClassInPackage.sun.awt.geom

    My class imports sun.awt.geom.Crossings in order to implement a similar-to-java.awt.Polygon intersects method, upon float values. This takes place in an applet. The all known error message appears in the java console:
    java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.awt.geom)
    I should actually sign my applet just to import that package!? (lets say the policy file is not an option in my case)
    Why is that package different in such a way, than other packages? Is it not located together with all the other classes that compose the jre? (Also, is it documented somewhere?) May it be that the jre of the client that runs the applet would not necessarily provide this package or is it a standard in the J2SE jre?
    When an applet imports java.awt.Polygon (wihch imports sun.awt.geom.Crossings) no AccessControlException in thrown. I wonder.
    Thanks.
    mplexus2

    all the sun.* packages are offlimits to Applets since they contain code that could comprimise the system, and they do not contain any security checks. There may be an exception in one of the sun's get audio file.

Maybe you are looking for