 |
BOOK: Beginning Java 2  | This is the forum to discuss the Wrox book Beginning Java 2, SDK 1.4 Edition by Ivor Horton; ISBN: 9780764543654 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning Java 2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 6th, 2004, 03:57 PM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Saving Shape objects as Bitmap or Jpeg
Using Horton's sketcher code I would like to save the sketch as either a bitmap or jpeg file. I have code for saving an Image object and am looking for any pointers I can find befor spending more time on this.
(this topic has been posted in Java forum)
thanks for your time - JoePates
|
|

August 7th, 2004, 05:16 AM
|
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by JoePates
Using Horton's sketcher code I would like to save the sketch as either a bitmap or jpeg file. I have code for saving an Image object and am looking for any pointers I can find befor spending more time on this.
(this topic has been posted in Java forum)
thanks for your time - JoePates
|
It is better to use a drawing program like Paint Shop Pro to create a sketch and save it. The sketcher we create in Ivor Horton's Beginning Java 2 is meant to be an example of a large program. The way to benefit from Sketcher is to write (type over!) the Java source code as we move along studying the book.
For instance: it teaches us to create and use OUR OWN SERIALIZATION to save a sketch.
Regards
Francis
|
|

August 7th, 2004, 05:06 PM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Francis;
Yeah thats pretty obvious. Do you have any ADVICE to give on saving a Shape object as a Bitmap. Besides, if I was going to use existing software what would be the point of even learning how to create and USE OUR OWN SERIALIZATION?
|
|

August 8th, 2004, 08:45 AM
|
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by JoePates
Francis;
Yeah thats pretty obvious. Do you have any ADVICE to give on saving a Shape object as a Bitmap. Besides, if I was going to use existing software what would be the point of even learning how to create and USE OUR OWN SERIALIZATION?
|
OK, if you browse the index of
JavaTM 2 Platform, Standard Edition, v 1.4.2 API Specification
http://java.sun.com/j2se/1.4.2/docs/api/
like I did, you won't find the word Bitmap, strange...
Of course there are the
java.awt.image
javax.imageio
packages and these are extensive (as usual)
No, I don't know the answer to this, because I have not studied chapter 17 yet, which deals with images, nor chapter 16 on printing and the practice of serialization.
Why not submit your question through the appropriate channels:
Developer Forums
Java Technology Forums
http://forum.java.sun.com/index.jsp
Developer Forums
Forum: New To Java Technology
http://forum.java.sun.com/forum.jsp?forum=54
To be honest: this forum is quite dead, it's only me here, and my book, with Ivor Horton smiling on the cover, telling me it is easy, which it isn't..
& Good day to you Sir
|
|

August 8th, 2004, 09:06 AM
|
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
P.S.
JPEG - Static variable in class javax.print.DocFlavor.BYTE_ARRAY
Doc flavor with MIME type = "image/jpeg", print data representation class name = "[B" (byte array).
JPEG - Static variable in class javax.print.DocFlavor.INPUT_STREAM
Doc flavor with MIME type = "image/jpeg", print data representation class name = "java.io.InputStream" (byte stream).
JPEG - Static variable in class javax.print.DocFlavor.URL
Doc flavor with MIME type = "image/jpeg", print data representation class name = "java.net.URL".
JPEGHuffmanTable - class javax.imageio.plugins.jpeg.JPEGHuffmanTable.
A class encapsulating a single JPEG Huffman table.
JPEGHuffmanTable(short[], short[]) - Constructor for class javax.imageio.plugins.jpeg.JPEGHuffmanTable
Creates a Huffman table and initializes it.
JPEGImageReadParam - class javax.imageio.plugins.jpeg.JPEGImageReadParam.
This class adds the ability to set JPEG quantization and Huffman tables when using the built-in JPEG reader plug-in.
JPEGImageReadParam() - Constructor for class javax.imageio.plugins.jpeg.JPEGImageReadParam
Constructs a JPEGImageReadParam.
JPEGImageWriteParam - class javax.imageio.plugins.jpeg.JPEGImageWriteParam.
This class adds the ability to set JPEG quantization and Huffman tables when using the built-in JPEG writer plug-in, and to request that optimized Huffman tables be computed for an image.
JPEGImageWriteParam(Locale) - Constructor for class javax.imageio.plugins.jpeg.JPEGImageWriteParam
Constructs a JPEGImageWriteParam.
JPEGQTable - class javax.imageio.plugins.jpeg.JPEGQTable.
A class encapsulating a single JPEG quantization table.
JPEGQTable(int[]) - Constructor for class javax.imageio.plugins.jpeg.JPEGQTable
Constructs a quantization table from the argument, which must contain 64 elements in natural order (not zig-zag order).
The API index does give us clue as to the implementation of the JPEG standard, but I must add that I advise strongly against using JPEG to save the drawings made in Sketcher.
GIF would be the natural choice for these!
GIF - Static variable in class javax.print.DocFlavor.BYTE_ARRAY
Doc flavor with MIME type = "image/gif", print data representation class name = "[B" (byte array).
GIF - Static variable in class javax.print.DocFlavor.INPUT_STREAM
Doc flavor with MIME type = "image/gif", print data representation class name = "java.io.InputStream" (byte stream).
GIF - Static variable in class javax.print.DocFlavor.URL
Doc flavor with MIME type = "image/gif", print data representation class name = "java.net.URL".
Did you know that you can make a screen picture? (I've never done this, but your computer should support this facility)
Then it should be possible to save any Sketcher drawing.
Even the ones where XOR mode isn't working appropriately, and you get all these nice effects, where moving a Shape creates the most crazy mouse movement artefacts on the screen, that are not stored in the Model, and thus cannot be serialized.
;0)
Francis
|
|

August 8th, 2004, 09:39 AM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Francis;
Thanks very much for your time and effort on this. I have been looking through the API's and have come across the info that you posted as well as info in JAI on saving images.
I am working on a school project that requires us to make a simple animation system and saving the image(s) in a format that can be displayed by en editing program is part of the project.
It is not important as to what format the image is stored as, bmp, jpeg, gif. (may be extra marks if more than one format is offered!)
Thanks again.
P.S. I have posted this elsewhere with little feedback so far.
|
|

August 8th, 2004, 10:15 AM
|
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I've heard the voices of many developers crying out loud for support in saving images as .gif format. It seems the patent expires this year, and we all hope the new Java 1.5. API will allow us this new feature.
Good luck with your studies!
Francis
the Hague
|
|
 |