Creating an ImageReader

J

jasonM

Hi,

I've created a program in Java to compare images and display pixel
differences. The ImageReaders I have available on my system are for
GIF, JPG, and PNG images. I've searched for an ImageReader that would
work with XWD images without any success. Can anyone point me to a
resource that describes how to write an ImageReader for a particular
format?

Thanks,

Jason Mazzotta
 
S

Stefan Rybacki

jasonM said:
Hi,

I've created a program in Java to compare images and display pixel
differences. The ImageReaders I have available on my system are for
GIF, JPG, and PNG images. I've searched for an ImageReader that would
work with XWD images without any success. Can anyone point me to a
resource that describes how to write an ImageReader for a particular
format?

Well, I'd start by subclassing ImageReader.
Also find information of the XWD format so you can decode it.
 
N

Nelson Ashton

Well, I'd start by subclassing ImageReader.
Also find information of the XWD format so you can decode it.

I'D start by first seeing if someone else has already written one. If
an ImageIO plugin for a particular format already exists, you can just
stick its jar in your classpath and maybe edit a file, and ImageIO
will automatically find a reader for that format when you use
ImageIO.read(thefile).

If you can't find one (with a suitable license), then I guess you'll
have to make one.
 
S

Stefan Rybacki

Hi
>...
>
I'D start by first seeing if someone else has already written one. If
an ImageIO plugin for a particular format already exists, you can just
stick its jar in your classpath and maybe edit a file, and ImageIO
will automatically find a reader for that format when you use
ImageIO.read(thefile).

If you can't find one (with a suitable license), then I guess you'll
have to make one.

Well I assumed the OP didn't find a suitable one since he actually stated that
he didn't.
> I've searched for an ImageReader that would
> work with XWD images without any success.

Stefan
 
N

Nelson Ashton

]
If you can't find one (with a suitable license), then I guess you'll
have to make one.

Well I assumed the OP didn't find a suitable one since he actually stated that
he didn't.

He said he didn't find a suitable one ON HIS SYSTEM. He said "the
ImageReaders I have available on my system are for
GIF, JPG, and PNG images" and that he didn't see any for XWD.

Perhaps he meant to say he didn't find any for XWD on his system OR
the net but he didn't actually say that, and I assumed the possibility
that he hadn't yet searched the net.

If he has, then he's probably stuck with rolling his own.

FWIW, a bit of googling on my part didn't turn up an XWD plugin,
though that doesn't mean one isn't out there somewhere.
 
J

jasonM

Nelson said:
]
If you can't find one (with a suitable license), then I guess you'll
have to make one.

Well I assumed the OP didn't find a suitable one since he actually stated that
he didn't.

He said he didn't find a suitable one ON HIS SYSTEM. He said "the
ImageReaders I have available on my system are for
GIF, JPG, and PNG images" and that he didn't see any for XWD.

Perhaps he meant to say he didn't find any for XWD on his system OR
the net but he didn't actually say that, and I assumed the possibility
that he hadn't yet searched the net.

If he has, then he's probably stuck with rolling his own.

FWIW, a bit of googling on my part didn't turn up an XWD plugin,
though that doesn't mean one isn't out there somewhere.

Hi,

Thanks for the reply. When I said that I searched and couldn't find a
suitable ImageReader, I meant online. Sorry I didn't make that
clear. If I do role my own, I'm still pretty much in the dark. Can
someone point me to a reference that will describe how exactly I go
about writing my own ImageReader?

Thanks,

Jason
 
J

jasonM

jasonM said:
Nelson said:
]
If you can't find one (with a suitable license), then I guess you'll
have to make one.

Well I assumed the OP didn't find a suitable one since he actually stated that
he didn't.

He said he didn't find a suitable one ON HIS SYSTEM. He said "the
ImageReaders I have available on my system are for
GIF, JPG, and PNG images" and that he didn't see any for XWD.

Perhaps he meant to say he didn't find any for XWD on his system OR
the net but he didn't actually say that, and I assumed the possibility
that he hadn't yet searched the net.

If he has, then he's probably stuck with rolling his own.

FWIW, a bit of googling on my part didn't turn up an XWD plugin,
though that doesn't mean one isn't out there somewhere.

Hi,

Thanks for the reply. When I said that I searched and couldn't find a
suitable ImageReader, I meant online. Sorry I didn't make that
clear. If I do role my own, I'm still pretty much in the dark. Can
someone point me to a reference that will describe how exactly I go
about writing my own ImageReader?

Thanks,

Jason

I think I found a starting point :

https://gif-plugin.dev.java.net/

It's for GIF images, but it should allow me to cut and paste stuff XWD
relevant code in place.
 
S

Stefan Rybacki

jasonM said:
Nelson said:
]
If you can't find one (with a suitable license), then I guess you'll
have to make one.
Well I assumed the OP didn't find a suitable one since he actually stated that
he didn't.
He said he didn't find a suitable one ON HIS SYSTEM. He said "the
ImageReaders I have available on my system are for
GIF, JPG, and PNG images" and that he didn't see any for XWD.

Perhaps he meant to say he didn't find any for XWD on his system OR
the net but he didn't actually say that, and I assumed the possibility
that he hadn't yet searched the net.

If he has, then he's probably stuck with rolling his own.

FWIW, a bit of googling on my part didn't turn up an XWD plugin,
though that doesn't mean one isn't out there somewhere.

Hi,

Thanks for the reply. When I said that I searched and couldn't find a
suitable ImageReader, I meant online. Sorry I didn't make that
clear. If I do role my own, I'm still pretty much in the dark. Can
someone point me to a reference that will describe how exactly I go
about writing my own ImageReader?

Implement ImageReader, basically you need to parse the given input stream,
provide metadata information, image count and the actual image.
To parse an XWD have a look at the file definition

http://cvsweb.xfree86.org/cvsweb/xc/include/XWDFile.h?rev=1.2

Stefan
 
J

John B. Matthews

Nelson Ashton said:
He said he didn't find a suitable one ON HIS SYSTEM. He said "the
ImageReaders I have available on my system are for GIF, JPG, and PNG
images" and that he didn't see any for XWD.

The OP said, with some ambiguity: "The ImageReaders I have available on
my system are for GIF, JPG, and PNG images. I've searched for an
ImageReader that would work with XWD images without any success."
Perhaps he meant to say he didn't find any for XWD on his system OR
the net but he didn't actually say that, and I assumed the
possibility that he hadn't yet searched the net.

If he has, then he's probably stuck with rolling his own.

FWIW, a bit of googling on my part didn't turn up an XWD plugin,
though that doesn't mean one isn't out there somewhere.

OP: Both Ashton and Stefan are correct. You may need to extend ImageReader,
and you should keep looking.

X Window Dump (XWD) and links to source are discussed here:

<http://en.wikipedia.org/wiki/Xwd>

The format is described here:

<http://www.fileformat.info/format/xwd/>

Here's a guide to writing ImageReader plug-ins:

<http://java.sun.com/j2se/1.4.2/docs/guide/imageio/spec/extending.fm3.html>

Here is the header for the sample image,

<http://www.fileformat.info/format/xwd/sample/index.htm>:

$ /usr/X11R6/bin/xwud -dumpheader -in MARBLES.XWD
window name: xwud:
sizeof(XWDheader): 100
header size: 100
file version: 7
pixmap format: 2
pixmap depth: 24
pixmap width: 1419
pixmap height: 1001
x offset: 0
byte order: 1
bitmap unit: 8
bitmap bit order: 1
bitmap pad: 8
bits per pixel: 24
bytes per line: 5676
visual class: 4
red mask: 16711680
green mask: 65280
blue mask: 255
bits per rgb: 8
colormap entries: 0
num colors: 0
window width: 1419
window height: 1001
window x: 0
window y: 0
border width: 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top