Bespoke Composites

I tried to implement a Composite that would give all my drawing a tint of a given colour. However, I got lots of messages about not support yet. Sorry, I don’t have the logs handy to post. Are we not able to implement Composites of own as yet?

Kev

sure you can.

All you gotta do is implement the java.awt.Composite and the java.awt.CompositeContext interfaces.

I believe you require permissions to do it in an Applet though. (you could use the Composite to get pixel values from the users display… hardly the biggest of security concerns ::slight_smile: but then the ppl who design Suns APIs obviously don’t live in the real world :P)

oh… and using a Custom compositing rule will be slow as **** :-*

[quote](you could use the Composite to get pixel values from the users display… hardly the biggest of security concerns ::slight_smile: but then the ppl who design Suns APIs obviously don’t live in the real world :P)
[/quote]
It would be a big concern if you could get pixel values from anywhere on the user’s display. But I can’t see how you would be able to get pixel values for anything other than images that the applet already had access to.

I think the rationale behind it is;
if reading back from vram is allowed in any way,
you open yourself upto the possibility the programmer can find a way around any checks regarding exactly where in vram reading is allowed.

Its far easier from a bug prevention POV, to simply deny readback altogether.

Still, it does suk :wink:

Custom compositing to the screen (or VI) is not implemented in 1.4-1.4.2.

[quote]Custom compositing to the screen (or VI) is not implemented in 1.4-1.4.2.
[/quote]
urk, thats what happens when I give advice without testing :wink:

Does it affect drawing direct to Components as well, or is it just when using BufferStrategy and/or VolatileImages?

e.g. would this work?


Graphics2D g2d = (Graphics2D)frame.getGraphics();
g2d.setComposite(new MyCustomComposite());
g2d.drawImage(blahblah,0,0,null);

[quote]Custom compositing to the screen (or VI) is not implemented in 1.4-1.4.2.
[/quote]
Will it be implemented in 1.5?

Damn I hope so :slight_smile:

No worries Abuse, I only just got back to this thread :slight_smile:

Kev

Nope, you’ll get the exception about “getRaster: not implemented yet”. It may work for VI, but will be dog-slow at first, and then the vi will be punted to system memory (because we have to poke the pixels)

Sigh… Unfortunately, I don’t think so. There were no demand for this (that’s why it’s still broken since 1.4), and the fix isn’t trivial.