Re: [JAVA2D] General paths and transforming coordinates in double precisions.

2001-03-16 Thread Jerry Huxtable

Why are general paths expressed *only* in simple precision?

Translating a Rectangle2D.Double to its origin fails by an order of
magnitude of 10 e-6. As a consequence, getBounds() might be shifted
by 1 pixel.
This limitation makes it difficult to write generic code for any Shape.

Does anybody knows if this is going to be fixed in the next JDK?

I don't know about that, but it's easy to write your own
implementation of GeneralPath or something similar which uses
doubles. As long as it implements the Shape interface and you write a
PathIterator for it it'll work fine. I do this in my map viewer to
get high precision and because I need to edit the paths.

Jerry

Jerry Huxtable
http://www.jhlabs.com

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



[JAVA2D] RescaleOp trouble

2001-03-13 Thread Jerry Huxtable

Hi,

I didn't get any reply to my posting on LookupOp :-( so I'll try a
different tack. I'm trying to use RescaleOp  on an image using code
like this:

image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
//draw some stuff here
BufferedImageOp op = new RescaleOp(1.0f, 0.0f, null);
op.filter(image, image);

When I do this I get an IllegalArgumentException: "Number of bands in
src 4 does not equal number of bands in dest 2". Seeing as the source
and destination are the same image, this is surprising to say the
least. If I put null as the second argument to filter I don't get the
exception, and neither do I get any pixels - the whole result image
has alpha set to zero. I have the same trouble with LookupOp. What am
I doing wrong?

Thanks,

Jerry
Jerry Huxtable
http://www.jhlabs.com

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



[JAVA2D] LookupOp

2001-03-06 Thread Jerry Huxtable

Hi,

I'm having trouble with LookupOp on Java 1.3 and hope someone will be
able to help. I'm trying to fill an image of TYPE_INT_ARGB with a
given color while leaving the alpha channel intact and this should be
easy to do with LookupOp. If I create a ByteLookupOp like this:

byte[] rt = new byte[256];
byte[] gt = new byte[256];
byte[] bt = new byte[256];
for (int i = 0; i  255; i++) {
rt[i] = r;
gt[i] = g;
bt[i] = b;
}
byte[][] table = { rt, gt, bt };
LookupTable lookup = new ByteLookupTable(0, table);
op = new LookupOp(lookup, null);
image = op.filter(image, null);

The Java VM crashes when I call op.filter(). This happens on both
Solaris and Windows. If I replace the ByteLookupOp with a
ShortLookupOp I get an exception saying that the destination image
has only two bands whereas the source has 4 bands. I got this code
from the "Java 2D Graphics book" by the way.

I decided to go my own way and write a class:

class ColorLookupTable extends LookupTable {
private byte r, g, b;

public ColorLookupTable(Color color) {
super(0, 4);
r = (byte)color.getRed();
g = (byte)color.getGreen();
b = (byte)color.getBlue();
}

public int[] lookupPixel(int[] src, int[] dst){
if (dst == null)
dst = new int[src.length];
dst[0] = r;
dst[1] = g;
dst[2] = b;
dst[3] = src[3];
return dst;
}
}

This works fine, but I have three questions: Why do I have to make my
array have the order RGBA (by experiment) when my image is
TYPE_INT_ARGB? Is using my own class slower as it seems that
ByteLookupTable is treated as a special case and performed in native
code (hence the VM crash)? Am I going about things in completely the
wrong way?

Thanks

Jerry

Jerry Huxtable
http://www.jhlabs.com

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



Re: [JAVA2D] The VM infinite loop when drawing with large coordinate values

2001-01-20 Thread Jerry Huxtable

This is a nasty problem for real world applications(like the one I'm
currently developing). Any help would really be appreciated,

It's a big problem for us as well. We worked round it by implementing
a Liang-Barsky path clipper to clip everything to a bit larger than
the window size before drawing - it's not too hard but it's a pain to
have to do it.

Jerry

Jerry Huxtable
http://www.jhlabs.com

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



Re: [JAVA2D] Printing performance and spool size

2000-12-14 Thread Jerry Huxtable

Thanks Phil for some very useful tips on printing performance. They
inspired me to have another look at our printing code and I've
managed to improve the print quality massively to the point where
we're quite happy (although we'd like some more speed!).

Now in order to improve the quality, we need to know the printer
resolution. The Java almanac for 1.3 has a PageAttributes class with
a getPrinterResolution method, but according to the index, no method
returns such an object. How do I get the printer resolution?

Thanks,

Jerry
Jerry Huxtable
http://www.jhlabs.com

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



Re: [JAVA2D] JAVA2D-INTEREST Digest - 11 Dec 2000 to 12 Dec 2000 (#2000-183)

2000-12-13 Thread Jerry Huxtable

I have a component that takes several minutes and 10MB of spool file to
print. I would like to know if anyone has any optimization tips to share.

I found that using a white background seems to improve the spool size
considerably.

I plan to tweak the rendering hints. I figure out that using the lowest
quality rendering hints on a printer shouldn't deteriorate the end result
too much because printers have very high resolutions. I guess this will
mostly improve the time, but perhaps also the space?!

Only 10Mb? - ours are usually about 100Mb and I've yet to find a
printer which can print them. Some things you can try are to give it
the lowest quality rendering hints. Definitely turn off antialiasing,
don't draw images which have an alpha channel, and don't use any
fancy alpha compositing in your rendering - any of these things will
force Java2D to decide to render the whole page as an image instead
of sending stuff directly to the printer (I'm assuming these are
PostScript spool files). If you do all this, things may or may not
improve. We have terrible trouble with Java printing drawing stuff at
screen resolution and producing enormous spool files. We once had an
A4 page which took two hours to print. We solved the problem for
PostScript printers by producing PostScript directly and sending it
to the printer and we're currently investigating using native methods
to do direct GDI calls for Windows to bypass Java printing altogether.

Jerry

Jerry Huxtable
http://www.jhlabs.com

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



[JAVA2D] Warping Images

2000-11-08 Thread Jerry Huxtable

Hi,

Has anyone any sample code or words of wisdom for writing a
BufferedImageOp for warping images (non-affine). I have written an
ImageFilter which does the warping with bilinear interpolation and I
know how to use JAI to do it, but I really need a BufferedImageOp and
it all looks way too complicated.

Thanks,

Jerry
Jerry Huxtable
http://www.jhlabs.com

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



Re: [JAVA2D] Java 2D and Mac

2000-09-12 Thread Jerry Huxtable

I happen to have the same problem.  I need to support Java 2D on the Mac.
If I am not wedded to using Applets (IE 5.0 only supports jdk 118 on
Mac side, Netscape is worse),
is there some way to then bundle the Java 2D JDK 1.[2-3] with a Java
Application for the Mac ?

Any assistance regarding this would be greatly appreciated.

OK, since nobody else has replied to this

The word is that there will never be Java 2, and hence Java2D for the
Mac under MacOS 9. Under MacOS X, there will be Java 1.3 from the
very beginning, which does use the Quartz rendering to achieve fast
performance. I think the public beta of MacOS X is out this month,
but I may be wrong. Basically, Java 2 is too big a beast for Apple to
port it all to an un-unix-like OS like MacOS in a reasonable
timescale, and the license agreement with Sun prevents them releasing
a subset of Java 2.

Now for alternatives: There was a pure java implementation of the
Java2D API a long time ago (well before Java was released) called
ishtek2d. I've no idea if it still exists, but it did run under MRJ
although it was slow (it was trying to do too much: antialiasing,
full alpha compositing etc.). I did investigate using Mac native
graphics with the 2D API as a spare time project, but I didn't have
the spare time. The major difficulty is that BufferedImage and so
forth is a large API which is very bound up with the internals of
almost every part of Java2D and that there are many AWT classes which
have been extended or have different superclasses in Java2D (e.g.
IndexColorModel). If anyone knows of any other alternatives, I'd be
pleased to hear about them.

Jerry Huxtable
http://www.jhlabs.com

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



[JAVA2D] Printing resolution

2000-07-26 Thread Jerry Huxtable

All this talk of PageAttributes and printing has reminded me of a
strange problem I have here. I'm using JDK1.3 under Windows 98 and
printing to an Epson Stylus printer. If I print a load of vector
stuff, lines circles etc. then everything gets printed at printer
resolution and is fine. If, however I print a background image, the
resolution of all the vectors goes down to what likes like about 100
dpi, but may be 72dpi. How can I avoid this?

Jerry
Jerry Huxtable
http://www.jhlabs.com

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



Re: [JAVA2D] Serializable JAVA2D implementation

2000-05-04 Thread Jerry Huxtable

At 12:00 am -0700 3/5/00, Automatic digest processor wrote:
I have currently worked out a solution which serializes the Java2D objects
(Rectangle2D.Double and Point2D.Double) in the class that implements
the polygon objects (using writeObject and readObject methods). This is
not a bad work-around, but I would expect that somebody had already
implemented serializable Java2D classes. In that case, one
would not have to bother about serializability at the application level.

I ran into the serializing problem a while back when writing a map
viewer. I managed to work round it by extending Point2D.Rectangle
etc, making the classes serializable, and then being very careful to
only ever create my versions and to always convert any which came
back from Java2D functions (sounds hairy, but for my purposes was
quite easy).

As for being able to edit polygons: I wrote my own version of
something like GeneralPath which had APIs for adding, deleting,
moving points. As long as it implements Shape, it's as good as a
GeneralPath as far as Java2D is concerned. [There are all sorts of
fun things you can do with Shape. e.g. write a regular polygon class
which just has number of sides, radius and centre just by writing a
PathIterator for it]

Jerry Huxtable
http://www.jhlabs.com

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".