Can anyone give me a hint on how to a get a byte[] array or InputStream from the Image/Icon object. Need to store an image that doesn't come from the filesytem in the DB's LONG RAW field. I can get int[] with PixelGrabber class, but how does one convert it to byte[]? thanks...
I am having a similar problem: I want to convert an java.awt.image into a byte array NOT into an int array. Shouldn't there be a way to specify a custom colorspace and colormodel to pixelgrabber so that it grabs the pixels and puts them into a byte array opposed to a int array??? Or is this just not possible The image ONLY exists as a java.awt.image NEVER as anything else so there isn't a prior step that I can intercept (which is how the example above does it) Thanks
ok this is the sort of problem I am having too. I understand all of the above method apart from the baseClass stuff!?!?! can anyone explain that to me? How I should call this method?
The Class argument is the class whose class loader will be asked to locate the file (see getResource Method Detail in Class api). If it is simply the enclosing class you can use the keyword this. If called from a static context you will need to use the MyClass.class form of class reference. If called from within an inner class you can use a member variable reference created at construction.
See the tutorial page How to Use Icons, especialy the section Loading Images Using getResource.