Trouble printing an image that has BufferedImage composited onto it

I make a complex image by adding several BufferedImages that have been rotated. The result appears fine in a JComponent, but when I print the same image, the only part of the BufferedImage that comes through is the part located where the BufferedImage would have been if not rotated.
If the rotation is 90 degrees or more in either direction (that is, if no image will appear), I get the following error message:
java.awt.image.RasterFormatException: Transformed width (0) is less than or equal to 0.
     at java.awt.image.AffineTransformOp.createCompatibleDestImage(AffineTransformOp.java:430)
     at java.awt.image.AffineTransformOp.filter(AffineTransformOp.java:209)
     at sun.print.PathGraphics.drawImage(PathGraphics.java:1745)
     at RotateBuffIm.painter(RotateBuffIm.java:99)
My system is:
Windows XP, service pack 3
HP LaserJet 1022
BlueJ 2.5.0
Java jdk 1.6.0_12
My source code is:
import java.awt.*;
import java.awt.font.*;
import java.awt.print.*;
import java.awt.image.*;
import java.awt.geom.*;
import javax.swing.*;
* RotateBuffIm draws a BufferedImage and
* composites it onto another image at an
* arbitrary angle. That part of the image
* not in the area that it would occupy if
* it were not rotated, is lost. If the
* rotation reaches +/- 90 degrees, an
* exception is generated and the compositing
* fails.
public class RotateBuffIm extends JComponent
implements Printable {
static boolean printIt = true;
RotateBuffIm() throws PrinterException {
JFrame frame = new JFrame();
frame.setSize(800,646);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setOpaque(true);
frame.getContentPane().add(this);
frame.setVisible(true);
if (printIt) {
Paper paper = new Paper();
paper.setSize(576, 792);
paper.setImageableArea(72, 72, 432, 646);
PageFormat pF = new PageFormat();
pF.setPaper(paper);
pF.setOrientation(PageFormat.LANDSCAPE);
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(this, pF);
job.print();
* paintComponent(g)and print(g, pf, pg) both call
* painter(g), which does the drawing.
public void paintComponent(Graphics g) {
painter(g);
public int print(Graphics g, PageFormat pf, int pg) {
if(pg >0) return Printable.NO_SUCH_PAGE;
painter(g);
return Printable.PAGE_EXISTS;
* painter draws one BufferedImage consisting
* of a rectangle with a label inside, and
* composites it onto the page-sized field at
* an arbitrary location and angle.
private void painter(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.WHITE);
g2.fillRect(0, 0, 792, 612);
g2.setColor(Color.BLACK);
g2.setComposite(
AlphaComposite.getInstance(
AlphaComposite.SRC_OVER));
int angle = 90;
int x = 300; int y = 300;
int w = 200; int h = 50;
BufferedImage bI = new BufferedImage(
w, h, BufferedImage.TYPE_INT_ARGB);
Graphics2D gBI = bI.createGraphics();
gBI.setColor(Color.BLACK);
gBI.setBackground(Color.WHITE);
gBI.drawRect(0, 0, w-1, h-1);
TextLayout tL = new TextLayout(
"BufferedImage at angle "+angle+" deg",
gBI.getFont(), gBI.getFontRenderContext());
int yT = (int)(h*.5 +
(tL.getAscent()-tL.getDescent())/2);
int xT = (int)(w*.5 +
( -tL.getAdvance())/2);
tL.draw(gBI, xT, yT);
AffineTransform at = new AffineTransform();
at.setToIdentity();
at.rotate(Math.toRadians(angle));
AffineTransformOp ato =
new AffineTransformOp(at, null);
try {
g2.drawImage(bI, ato, x, y);
} catch(Exception e) {
System.out.println("draw failed");
System.out.println(e.toString());
What do I not understand? This seems to be a failure to rotate a clipping shape to match the image. I'm at a pretty basic level. Thank you for any enlightenment.

the method
g2.drawImage(bI, ato, x, y);will either call
ato.filter(bI,null);or
ato.filter(bI,bI);The printer graphics might be calling the later one. So you end up getting this result
the only part of the BufferedImage that comes through is the part located where the BufferedImage would have been if not rotatedTry changing the statement to
g2.drawImage(ato.filter(bI,null),x,y,null);

Similar Messages

  • Is it possible to print out an image that has had a colorMatrixFilter applied to it?

    Is it possible to print out an image that has had a colorMatrixFilter applied to it?
    I applied the following code to print the ViewStack which contain Image
    printJob = new FlexPrintJob();
    printJob.printAsBitmap = true;              
    printJob.addObject(printJobEvent.viewArea, FlexPrintJobScaleType.SHOW_ALL);
    printJob.send();
    Is there any method to print out image with Brightness/Contrast/Hue/Statuation/Rotate adjusted?  Thanks

    If you give the to-do items due dates within the week in question, then checking the "To Dos with Due Dates" option in the calendar pringing dialog will print them. I have not found a way to get To-Dos without a date in the relevant week to print on a weekly calendar.
    Apple ][   Other OS  

  • How do I print a label that has the artist/album on the side?

    I have tried printing labels with iTunes but these are apparently for the thin CD covers. I am looking for a way to use iTunes to print out labels that has the artist and album on the side for use with regular CD covers so that I can look at the case from the side and know what CD it is.
    I have a third party shareware app that does this but I would like to use iTunes because it seems to be easier.
    TIA
    Rob\

    As mentioned here, iTunes does not print labels for the CD jewel case spines. I do use iTunes to print the front cover insert, but for the back cover I use a different program called "MyCoverCD" (aka. MCCD).
    See http://trad.applescript.free.fr/mccd_us.html
    This program can read the tracks names etc. from the current selection in iTunes and then print the back cover (with spines) or the front cover or various other options.

  • AirPrint laser printer for home that has "n" wifi capabilities

    Looking for an AirPrint laser printer for home that has "n" wifi capabilities. Was shocked to findout that most lasers don't do "N" wifi or high speed networking yet. Am seriously considering the HP LaserJet Pro P1102w printer, but just found out it is a nightmare to setup. Thought I could run it by USB port off my Timecapsule… Is anyone doing that? Can it do that? Is there a better alternative?

    Hi Scott,
    You can also setup the P1102w without the USB cable. What you need to do is to connect the printer via ad-hoc to your iPad first. With the default network settings the printer has its own SSID that you can select from the WiFi list on your iPad. Then open Safari and go into the EWS - either by the printers IP or host name. There you go to Network - Wireless and make the settings for your infrastructure network.
    However, both Laserjets will need a FW update that you install from a Mac or PC, so you may already use the install steps there to connect your printer to the network.
    Regards,
    Mandy

  • Need to print a report that has two pages but based on condition

    Hi
    Can someone help me. I have a report that has 2 pages and I need print it but not boths pages at the sametime.
    I have code ( the conditions)like this
    If (A=Y) then
    print Page 2
    else print page 1
    end if;
    Note: Where would I put the code. Please
    Thank you

    Some folks have written JavaScripts for such needs, but for only 6 pages I would simply do the following. 1. Crop all pages to show 1 and 4. Then print to a new PDF (not optimum, but will do the job). 2. Repeat for 2 and 5. 3. Repeat for 3 and 6. Now open one of them in Acrobat and the use insert pages to insert the other two files. Now rearrange the pages using the Pages display and save. That should do the job.

  • Can I embed layer styles to an image that has several layers and effects

    CS2
    PSD
    Windows
    I have a logo that has numerous layers - which I used to created depth with styles in PSD.
    If I scale my logo image 80% - the layer effects remain as it was at 100%.
    Can I do something to have the layer effects scale accordingly with the image?
    I tried flattening the image - but it doesn't keep all of the effects.
    Any thoughts.

    George that sounds great! Where is this resize dialogue?
    I usually go to transform > scale and enter percentage above in the tool bar or just drag the anchors accordingly.

  • How to make an action that creates a composite onto one image from a non specific source??

    Hi
    I'm trying to create an action, But having some trouble. I have a fair knowledge of CS4 and actions but this one is tricky.
    Basically i need to create a new document out of a folder full of images. These images need to have their opacity reduced to 40% and their blending mode changed to Colour burn. They then need to be copied onto the same canvas with a transparent background.
    Most of this is fine. But i need to make the action that is not image specific. So not the one i used to record it. This is for a mid process that is going to go between various other programs before display, and the hole process needs to be automated. When i hit pay or go through file-automate-batch it uses the images that i recorded with.
    I realise i havent explained this terribly well but any help would be much appreciated.
    Thanks
    Sam

    Basically i need to create a new document out of a folder full of images.
    You may have to look into Scripting to achieve something like this.
    You could ask in the Scriptimg Forum
    Photoshop Scripting
    But maybe it would suffice to insert the Menu Item
    File – Scripts – Load Files into Stack
    into the Action and then iterate through the Layers with [ or ] and reset the opacities and Blend Modes – but as Actions would not be able to change the number of repetitions of the operation conditionally a custom Script would still seem preferable. 

  • Making a PDF with an image that has both spot colour channel and alpha channel

    Hi I have a logo that was supplied to us as a PSD it has a transparent background, it also has a pantone colour channel. I have made a alpha channel from the transparent background as well.
    The graphic looks fine in InDesign (alpha channel selected in the import options), ie the background is transparent.
    But when we try to make a Hi Res PDF the result is that the graphic is on a solid white background.
    If I go back to the PSD and merge the spot channel with so that it is just CMYK and try again the PDF is fine, but we obviously loose the spot colour.
    How do you make a PDF with a transparent PSD that has a spot colour?

    You know that annoying response from support staff? "We cannot replicate your issue". Well....
    I created a PSD in CS5, with a bunch of process stuff, then loaded a spot color channel and painted in some pawprints using Pantone 172C:
    Saved this as a PSD file, default settings (maximize compatibility on, but it doesn't make any difference in this situation).
    Created a new InDesign document in CS5, added a gradient and some text, then placed the PSD.  ID understands the PSD has an inbuilt background so there's no need to bother with a dedicated alpha mask:
    Exported from ID using the High Quality Print option (PDF/1.4, which keeps the live transparency):
    Re-exported to PDF/X-1a (based on PDF/1.3 which flattens transparency) - looks exactly the same. In all cases the spot channel is intact and the see-through regions of the PSD are maintained.

  • How to print a form that has scrollable boxes data?

    I have developed a form that individuals can fill out a box that is scrollable to fit a certain number of letters.  On the screen after the form has been completed I want to print out the form but the scrollable box only prints what is seen on the screen rather than what has been typed in the entire box.  How can I get a printout of this form with all the information that is in the scrollable box?

    AcroForms do not have dynamic fields. One could use templates to spawn a new page that has a larger form field with the same name. Another approach would be to export the data to an FDF and then have a different copy of the form with much larger fields for those fields that are over flowing and import the FDF into that form.

  • Please help me load an .flv video that has been embeded onto a web page

    Hello there,
    I was hoping someone on this forum could please help me with one specific problem that I am having. I would like to embed the a flash player into an html page, and load the video from a service that has the streaming video provided.
    This is the context of the situation...
    We have created a site that was to be used on a showroom floor (no internet connection) and loaded the .flv videos at the local root level for the site.
    Now however, we would like it to be an online site. I have been able to use the flash "jw player"to load videos to play using the shadowbox javascript, but when I try to embed it onto a page and have it play, it isn't working and I am not sure why.
    Below is the code that is currently working to load the videos on the local root level.
    Might someone have any ideas on what I need to replace to have it load the videos from the streaming service?
    I would greatly appreciate any assistance that could be provided.  I can also provide a URL if it would help.
    I would GREATLY appreciate any assistance provided.
    <script type="text/javascript" src="swfobject.js"></script>
    <script type="text/javascript">
    swfobject.registerObject("player1","9.0.98","expressInstall.swf");
    </script>
    <object id="player1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="640" height="380">
    <param name="movie" value="player.swf" />
    <param name="allowfullscreen" value="true" />
    <param name="allowscriptaccess" value="always" />
    <param name="flashvars" value="file=assets/videos/Bob_Peebler.flv&image=images/videoStatic_Peebler.jpg" />
    <object type="application/x-shockwave-flash" data="player.swf" width="640" height="380">
    <param name="movie" value="player.swf" />
    <param name="allowfullscreen" value="true" />
    <param name="allowscriptaccess" value="always" />
    <param name="flashvars" value="file=assets/videos/Bob_Peebler.flv&image=images/videoStatic_Peebler.jpg" />
    <p><a href="http://get.adobe.com/flashplayer">Get Flash</a> to see this player.</p>
    </object>
    </object>

    Hello,
    Thanks  a lot for the reply.  However, I am pretty confident that the jw player supports the streaming video option, but as I mentioned that I was able to use it as a popup using the shadowbox javascript before. After doing a bit of investigating on how the videos are hosted, I am using "progressive download" method for these videos.
    I think the problem is that the player.swf is hosted on my website server -  and the videos are then hosted on the media hosting service.  I think that the player needs to be located on the media hosting service, and then embedded onto the page along with where to point to the .flv video.  Does that sound right?
    If so, the paramater I am using to embed the player as I mentioned in my original post is simply:
    <param name="movie" value="player.swf" />
    does the "value" then have to change to the http:// address for the video player.swf that would then be hosted on my video hosting service?
    Little help?
    Please let me know if there is anything I can provide to clarify the issue.
    Thanks
    M

  • Errors when trying to open up a disk image that has been comp. & encrypted.

    I have an old 15” PowerBook G4 that I purchased back in 2004 that I wanted to backup the data on in preparation to sell it. The PowerBook has Leopard (Mac OS 10.5) installed on it. I used my Leopard installation DVD to boot the computer up and then launched disk utility (v. 11.0 (252)). I wanted to make a disk image (.dmg) of my entire “Macintosh HD” partition, so after unmounting the partition (otherwise you get a “resource busy” error message), I selected File -> New -> “Disk Image From...(<hard drive partition>)”. The next screen presented me with a name to type in for the saved disk image file and options to compress and encrypt (128 or 256 bit AES) the image. I could not get the image to begin creation when I had both compression and encryption set. I kept getting the error message “Unable to create (error -60007)”. So, I opted to create the disk image with just compression selected. This worked fine and I was able to select the image (let’s call it disk_image1) and perform an Image -> “Scan Image for Restore...” successfully as well as mount the image and open up files (the verification process took a long time before the image mounted, but it was successful).
    Next, I moved the Firewire 800 external HD containing “disk_image1” to my new MacBook Pro (Snow Leopard installed) and opened up disk utility (v. 11.5.1 (298.1)). I was able to successfully mount the image and browse and open up files with this updated version of disk utility. I then attempted to convert the disk image I just created to a new disk image (let’s call it disk_image2) via Images -> “Convert...”. I selected “disk_image1” and then named the new image (disk_image2). I then selected compression and 128bit AES encryption, entered in a passphrase and started the process. Everything worked great in creating “disk_image2”, but when I tried to open up the image either in Finder or within disk utility, I got error messages. In disk utility, I got the message “Unable to attach “disk_image2.” (Authentication error).” and within Finder, I got “The following disk image couldn’t be opened” disk_image 2 (Authentication error). Note, I was never asked to provide the password I used to encrypt the image nor did I ever select to save it in my keychain. Just as a precautionary measure, I check my keychain and did not see the password for the encrypted image saved in there.
    Is there a bug within disk utility with the way a compressed & encrypted image is created or a problem with the authentication process for an encrypted image?

    I have not had this happen to me, but have read similar stories from people on these boards for years. I think saving an entire OS X boot disk to a disk image is asking for trouble. If anything goes wrong, one byte of data is copied incorrectly. it can render the entire image unmountable and all of the data in it inaccessible.
    I'd use Disk Utility's Restore button (or a program like SuperDuper or Carbon Copy Cloner) to make a complete copy of the hard drive onto its own hard drive, skipping the disk image. If any bit of data gets dropped then only one file is affected, instead of the whole works. Do you have any other stuff on that external drive? If not, just erase it and try again, copying everything directly to the drive instead of to a disk image.

  • How to detect alterations to a JPG image that has been saved as a PDF

    I have received a file containing a cancelled bank check that was downloaded from a bank website and saved as a PDF of the screenshot. Upon opening the PDF, it appears that some of the original hand-written text in the image has been altered. I believe this PDfFwas originally saved as a JPG, then altered, then saved as a PDF. Is there any way to determine if indeed the text has been altered in the file? Thanks!

    Not easily.  The bank's original version may have been a JPEG, then a screenshot was taken of that and saved as a PDF with unknown compression.  (really, who saves a screenshot as a PDF?)
    You can examine the PDF in a text editor to see what created it.  You can open it in Illustrator to see the layer data (which might show tampering).
    Beyond that you'd need an imaging forensics expert to look for tampering with the JPEG compressed image data (was it compressed more than once, was something significantly altered)?

  • How to select copy and paste an image that has a layer mask

    Hi,
    when I select, copy and paste the image it still has the content that I removed using the layer mask.
    I want to paste it over another psd whilst maintaing the transparency.
    Any help would be much appreciated.
    PSD is at
    http://sdrv.ms/16DoRft
    The small jpg is because I don't know what you will see in the skydrive psd
    Michael

    Wow that was so easy!
    Thanks!
    I spent at least half and hour trying to figure out why it wouldn't work.
    Michael

  • Help! How do I lengthen a still image that has another still image in front of it?

    When I try to lengthen the first of two adjacent still images in a single video track, I cannot do so. I can shorten the image, and I can both lengthen and shorten the duration of the second image, but that's all. I assume there is a very easy setting that I could change to avoid this problem, but I'm not coming across it. Any help is greatly appreciated!

    It will be worth your time to get a firm understanding of the Edit Modes about now.
    These are the key basic ways of editing clips in the timeline.
    An edit and trim, mode is what happens at the Edit Point between two clips or 2 images or 2 audio clips when these are adjacent to each other.
    The Edit Mode is indicated by different colored indicators shown at the Edit point. They have different functions like trim, ripple  etc....
    Take a look at Adobe TV for a  video  tutorial on the subject. Its easier than someone explaining in the thread.
    http://tv.adobe.com/product/premiere-pro/

  • Selectable items within an image that has links to other pages

    Hello All,
    I have recently started to learn Dreamweaver CS5 and need some help.  I have a jpeg of a floor plan and want the user to be able to click on the different rooms within the floor plan.  Once you click on the room it would take the user to another page with more details about that room.  For example, I have a floor plan and want to learn more about the Family Room. I would click on the room that says Family Room and it would take me to another page with details about the Family Room.  Any help would be appreciated.
    Thanks,
    Knowledge Seeker2

    I have recently started to learn Dreamweaver CS5 and need some help.
    The best approach would be to put DW away, and focus on learning HTML and CSS.  That will make picking up DW again ever so much easier.
    I would click on the room that says Family Room and it would take me to another page with details about the Family Room.  Any help would be appreciated.
    Use the hotspot tool to apply hotspots to the image.  Link each hotspot to the associated pages by selecting the hotspot and applying the link with the "Link" field of the Property inspector.

Maybe you are looking for