• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Advanced Imaging: Set up a RenderableOp Graph

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone!
I want to achieve the following:

I need to cut out an arbitrarily rotated rectangular area of undefined size of an image, then scale it to a predefined size in pixels.

Reading in this document from sun http://dlc.sun.com/pdf/806-5413-10/806-5413-10.pdf I figured, since I need to do this more than once, was to set up a tool chain, that does the following things:

(1) rotate the input image.
(2) crop the rectangular region out.
(3) translate the rectangular region, so it's origin is at (0,0) again.
(4) scale the rectangular region to the predefined square size.

The idea was, that once this processing chain was set up, I merely had to adjust the parameters of the region and the source image, then start sucking through pixels.

Here's what I ended up with as code:





Once I'd need pixels for a specific Image and Ellipse (This defines the dimensions and the angle of the cut out rectangle) I would just set the source Image and the new parameters and start grabbing pixels. This however fails on instantiation, telling me I have null parameters for for most of the JAI.cretaeRenderable() calls, that the crop operation cannot crop outisde the image and such.
What I first intended, was to set up the entire RenderableOp Graph with an empty constructor, and then set the variables needed to suck pixels through.
I then tried adding a non-empty constructor, since the were null pointers.
What is it I'm not getting?
Is the thing I want feasible with JAI anyway?
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Feasible, yes. Do-able, maybe. Sounds great, code looks well thought through. Does sink suck pixels from the source? I am sure it is not the sink that is throwing, it is likely that the null pointer exception can be traced to the correct basis. You can write a handy utility or wrapper class with a no-args list and .setImage(Image); set..... looks like you have done enough coding already to know where to look so what do we have that could throw null pointer exceptions in the antecedent code?

Sometimes these very appealing tools do not have all of the precedent code in place. Concept is great, logic is ( in overview ) very sane and workable. Where did you start with the project and where do you intend to go with it?
[ May 14, 2008: Message edited by: Nicholas Jordan ]
 
Phil Heuberger
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the answer. Since I only needed this whole thing for single channel Float-Type images (that were not in memory as JAI-RenderedOps in the first place) I ended up dropping JAI and coding a very specific method of cutting, cropping, scaling, rotating.
Thanks a lot anyway since, not in ANY other place than this board I got a reply of any kind, which speaks for the "big ol' moose"
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sure the Saloon will (humor) expect a round of drinks (/humor).

You can use the smileys.

I noticed several additional pointers since the first answer. One is that the Desktop model in java may have some calls that would lead to additional design ideas and Two I noticed in a Manning publication that I am using that there is sample code that does exactly what you asked. I will advise browsing the Manning site for titles. The caliber of work and style of work is something that would appeal to you.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic