Rotate, scale and print an image

I'm trying to rotate, scale and then print an image with the following code.
public int print(Graphics g, PageFormat pageFormat, int pageIndex)
                double DPI=72.0;
     if (pageIndex > 0)
          return(NO_SUCH_PAGE);
     else
          Graphics2D g2d = (Graphics2D)g;
          Paper paper = pageFormat.getPaper();
          int pWidth=(int) (DPI*paper.getWidth()/72.0);
          int piw=(int) (DPI*pageFormat.getImageableWidth()/72.0);     
          int pih =(int ) (DPI*pageFormat.getImageableHeight()/72.0);
          int xi=(int) (DPI*pageFormat.getImageableX()/72.0);
          int yi=(int) (DPI*pageFormat.getImageableY()/72.0);
          g2d.translate(0, pWidth);
          g2d.rotate(-Math.toRadians(90));
          g2d.drawImage(image, yi, xi. pih+yi,piw+xi, 0,0,image.getWidth(null), image.getHeight(null),null);
          g2d.rotate(Math.toRadians(90));
          g2d.translate(0, -pWidth);
}The image is shifted to the right and has some extra space on the left when it is printed out . I couldn't figure out why it does that.

Hmmmm That seems OK.
Are you sure the origin point of the central sprite is at a
locV that is
inbetween the orbiting sprites' min / max locV values? This
should do what
you need if the central object is at the right locV on stage
in relation to
the orbit path of the other sprites. Try moving it down in
relation to the
orbit sprite maybe?
Or try this on the central sprite to create an offset...
property my
on beginSprite me
my = sprite(me.spritenum)
end
on enterFrame me
my.locZ = my.locV + 50
end
Tinker with the 50 value until it looks right.
Cheers
Richard

Similar Messages

  • Scale and Crop with Image Alchemy

    Hello,
    We're using Digital Asset Managment with Image Alchemy for the conversion engine. Does anybody know how to configure a rendition set that scales and crops an image without distortion? So if you check-in a 1000x1500 pixel jpeg, it could scale it down and crop it to exactly 100x100 pixels.
    I've been looking through the Image Alchemy documentation, but haven't found this example yet.
    Thanks
    -Jason

    All you need to do is define an "ImageAlchemy" variable inside the "ImageManager_NameValues" ResultSet, DAM automatically knows when to use it for the rendition info. But instead of pointing to the ImageAlchemy executable file, I point to my script. For my conversion ResultSet's extEngine, I refer to an "ImageMagick" variable instead.

  • HT204135 Hi does anybody know how to tile print an image On an iMac ? So blow an image up and print that image on several pieces of paper . ? Appreciate any help Thank you Laura

    Hi does anybody know how to tile print an image On an iMac ? So blow an image up and print that image on several pieces of paper . ?
    Appreciate any help Thank you Laura

    There's an app for that...
    https://www.macupdate.com/app/mac/45688/tile-photos-fx
    Also see...
    http://www.blockposters.com

  • Superimposing layers each with isolated rotation, scale, and "move"ment

    This application seems like it should be easy, but two hours of experimentation have not solved the puzzle.  I have two transparent graphic eps files.  One I turn into a background layer by flattening it.  My need is to articulate detail on both files, which requires that the background image remain unchanging and the second (file's) image be superimposed over it and -independently- rotated, scaled, and moved.  Of course the second image is opened on some unknown variety of layer, but which I've been unable to discover.  That's my conundrum, should be intuitively simple but has proven impossible.  Anyone?

    "...is there a way to precisely scale, move, and rotate an image..."
    Yes, there is, and controls appear in the Options bar. For example, pictured here:
    the circled item allows a specific rotation, and the symbol appearing in the Edit > Transform image
    may be dragged to a particular "pivot point" in the image if you prefer.
    Note also that you may revise height & width (note the Link symbol to maintain proportion)
    The far left X and Y fields, when used with your keyboard arrow keys, provide for shifting an image in small, measured increments.

  • Preview Scale and Print

    Ok, so here is my dilemma.
    I open a PDF in Preview, I go to print it, set it to automatically scale and instead of scaling in the middle so it prints right, it scales to the bottom left and then gets cut off by the printer since its not inside the printer margins.
    Acrobat scales to the margins, but I want to use Preview because its faster. Anyway to set where preview scales?

    I don't know if my problem is exactly the same as yours, but I find that printing some PDFs in Preview cuts off the bottom of some documents. This doesn't happen when I convert the document to open in Adobe Reader and then print with the Reader print dialog box. I can't find any settings in the Preview dialog box to correct this: There is no longer a separate Page Setup dialog box, and the three radio buttons in the Preview print dialog box ("No automatic page scaling", "Scale each page to fit paper",and "Only scale down large pages") nor reducing the scale in the Scale text box seem to be able to correct this problem.
    The PDF document I was having problems with was created in Adobe Acrobat 8.1. Perhaps that has something to do with it.

  • How to default Preview/Finder to print "Scale to Fit Print Entire image/Fill Entire Paper"?

    Hello all,
    I have to print PDFs. Preview or printing directly from Finder prints scaling 100% and many many times the edges of the PDFs are left outside of the printing area. I have the correct paper size selected (A4) and actually the PDFs are also A4 but for some reason 100% zooms in a bit and cuts the sides of the print outside.
    I can of course fix this by selecting Scale to Fit and Print Entire Image but I do have to do this every single time I open a PDF. I want to make this option my default! And preferrably so that I can use CMD+P from Finder to print directly without having to open the PDF. I already know what is in it...
    I have tried different Terminal tricks I have found searching the web but no luck, this and others with Preview closed before executing the command
    defaults delete com.apple.Preview PVImagePrintingScaleMode
    Please help and make my life easier. Cannot be this hard.

    I got a work around for this. Instead of using RTF template, I used Microsoft Excel itself as template and did the formatting in excel.
    thanks,
    Vijay

  • How do you control the position and size of images, i.e,. photo to the printer?

    HP Officejet 8600
    Windows XP
    I am trying to figure out how to control the positon and size of photos or pics that are included in an email that I send to my printer via HP ePrint.
    This question was solved.
    View Solution.

    Hey Old_Salt,
    What model HP printer do you have?
    ePrint is a very simple system when it comes to printing, because it doesn't provide as many controls as one may be used to with a computer.  Many of the photosmart printers are designed to recognize a photo in ePrint and print the image to the proper photo paper.
    Jason
    -------------How do I give Kudos? | How do I mark a post as Solved? --------------------------------------------------------
    I am not an HP employee.

  • Scale and Crop .fla file?

    So I have an animated logo .fla file, there some some AS 2.0 in it. I basically need to scale and crop the entire file (just like you'd scale and crop an image in photoshop). Any easy way to do this in flash?

    There isn't any one click method for doing it if that's what you're looking for.  There is no cropping tool so that becomes a matter of resizing the stage by entering new dimension for it... similarly so to scale the stage.  As for the content, that all needs to be manually scaled as well.
    If you have all vector content, then you can always try scaling at the swf level.  Visually it should not be impacted.  Still, if you needed cropping for different stage dimensions, that would need to be done manually.

  • JS CS3 flag duplicate images with scale and rotation differnce

    I've been trying to cut down on the number of images a script I have would produce.  The old script would look for links that are being used multiple times and then just version the link which is fine.  What I am finding this that although a document may have one image linked 9 time 6 times out of the nine the image is scaled and rotated the same amount and the other 3 times the rotation and scaling also match. In this example the image only needs 2 versions the first as the original and the second with the scale and rotation of the image used 3 time let say.
    So to the code:
    The following code will work through the doc and create an array of the links as duplicates:
    function LinkUsage(myLink) {
        var myLinkCounter = 0;
            for (var myCounter =  0; myCounter < myDoc.links.length; myCounter++) {
            if (myLink.filePath == myDoc.links[myCounter].filePath) {
                myLinkCounter++;
        return myLinkCounter
    var myDoc = app.activeDocument;var myNumLinks = [];
    for ( var t = myDoc.links.length-1; t >= 0; t-- ){
        if(LinkUsage(myDoc.links[t])>1){
                myNumLinks.push(myDoc.links[t].id);
    Is there a way to loop through the array and only flag the differnent scale and roatations.  What I should get is that out of the multiple link uasage the image is only changed twice out of the 9 times used.
    I was trying to loop through the array and then loop through it within the loop to compare the link but this does not work for obvious reasons.
    for (var i=0  ; i <myNumLinks.length; i++){
        var valLink = myDoc.links.itemByID( myNumLinks[i]);
            if(valLink.parent.constructor.name == "Image"){
                for (var j=0  ; j<myNumLinks.length; j++){
                    if(myDoc.links.itemByID( myNumLinks[j]).parent.constructor.name == "Image"){
                        if(valLink.parent.parent.images[0].rotationAngle != myDoc.links.itemByID( myNumLinks[j]).parent.parent.images[0].rotationAngle){
                            $.write(myNumLinks[i]+"\n");
    Is what I am trying to do possible and if so any suggestions would be appreciated.
    Cheers, John.

    I think I might be one step closer to getting this to work.  I've been able to just capture the file path of the duplicates using:
    //count the number of times the link is used
    function LinkUsage(myLink) {
        var myLinkCounter = 0;
            for (var myCounter =  0; myCounter < myDoc.links.length; myCounter++) {
            if (myLink.filePath == myDoc.links[myCounter].filePath) {
                myLinkCounter++;
        return myLinkCounter
    //check if the filepath has been added to the array
    function chkVal(val){
        var compCount = 0;
        for(var arr =  0; arr < myNumLinks.length; arr++){
            if(val == myNumLinks[arr] ){
            compCount++;
        if(compCount >=1){
            return false;
            }else{
                return true;
    //check the links inthe doc
    var myDoc = app.activeDocument;
    var myNumLinks = [];
    for ( var t = myDoc.links.length-1; t >= 0; t-- ){
        if(LinkUsage(myDoc.links[t])>1){
            if(myNumLinks == 0){
                myNumLinks.push(myDoc.links[t].filePath);
                }else{
                    if(chkVal(myDoc.links[t].filePath)){
                        myNumLinks.push(myDoc.links[t].filePath);
    for (var i=0  ; i <myNumLinks.length; i++){
        $.write(myNumLinks[i]+"\n");

  • Scale and rotate a tiff image

    How do you scale and rotate a tiff image without running out of memory?
    I have been trying to scale the image and rotate it before i pass it to the DisplayJAI but i keep running out of memory.
    code i use to rotate the image.
    private Image rotateImage(boolean rotateRight)
    Image img = imageHolder.getInUseImageIcon().getImage();
    Image rot = null;
    int imageWidth = imageHolder.getInUseImageIcon().getIconWidth();
    int imageHeight = imageHolder.getInUseImageIcon().getIconHeight();
    int buffer[] = new int[imageWidth * imageHeight];
    int rotate[] = new int[imageWidth * imageHeight];
    try
    MediaTracker tracker = new MediaTracker (this);
    tracker.addImage (img, 0);
    tracker.waitForAll();
    PixelGrabber grabber = new PixelGrabber(img, 0, 0, imageWidth, imageHeight, buffer, 0, imageWidth);
    try {
    grabber.grabPixels();
    catch(InterruptedException e) {
    e.printStackTrace();
    if(rotateRight)
    for(int x = 0; x < imageWidth; x++)
    for(int y = 0; y < imageHeight; y++)
    rotate[(x*imageHeight)+y] = buffer[((imageHeight-y-1)*imageWidth)+x];
    else
    for(int y = 0; y < imageHeight; y++)
    for(int x = 0; x < imageWidth; x++)
    buffer[(y*imageWidth)+x] = rotate[((imageWidth-x-1)*imageHeight)+y];
    for(int y = 0; y < imageHeight; y++)
    for(int x = 0; x < imageWidth; x++)
    rotate[((imageWidth-x-1)*imageHeight)+y] = buffer[(y*imageWidth)+x];
    rot = createImage(new MemoryImageSource(imageHeight, imageWidth, rotate, 0, imageHeight));
    catch (Exception e)
    e.printStackTrace();
    return rot;
    this is the code i use to scaled the image.
    Image scaled = originalImage.getImage().getScaledInstance(
    (int)(currentWidth * 1.5),
    (int)(currentHeight * 1.5),
    Image.SCALE_FAST);
    I tried this method, it works and does what i want but the scrolling and loading is too slow.
    public void paintComponent(Graphics g)
    Graphics2D g2D = (Graphics2D)g;
    g2D.rotate(Math.PI/2, (int)dimension.getWidth()/2, (int)dimension.getHeight()/2);
    g2D.drawImage(image, 0,0,(int)dimension.getWidth(), (int)dimension.getHeight(), this);
    Help plss.

    Nvm got the answer :)

  • Preview and printing scale problems

    Hi,  I couldn't find a forum for preview. iphoto was the nearest...
    basically I am just trying to print an image opened in preview to a fairly small size and no matter what I do it always seems to scale it to fit the A4 paper size. If I go to Tools - Adjust size -  and make it quite a small image, (5cms across for example) when I go to print it it still just blows it up as before, all blurry and pixely.  really I don't seem to have lots of options, I have, of course, deselected the scale-to-fit button. I have tried reducing the number in the % field.  but nothing...

    Note the Scale option in the Print Dialogue - Just below 'Auto-rotate'. It's set to 394%. What happens if you set it to 100%?
    Regards
    TD

  • IBooks Author Scale and Rotate in preview

    I just started with iBooks Author. I made a simple book with several chapters and pages. When previewing the book in the iPad the pages zoom and rotate with a two finger gesture. Then snap bak to the default scale and rotation. Imagine trying to pinch to zoom, but having the page scale.
    How can make the pages use the standard zooming behavior with out rotating and hold the zoom without snapping back to the initial scle?

    Sorry about that. I haven't used that software before, but they appeared to fit the bill according to their descriptions.
    There is another program, Image Tricks, that is for Tiger and it will let you rotate images and save the changes.
    http://www.belightsoft.com/products/imagetricks/overview.php
    I can't find any hacks for Preview that will let you do what you want.
    PowerMac G5   Mac OS X (10.4.6)   1GB RAM, nvidia 6800 ultra, Apple 30" Cinema Display

  • Rotate, crop, and retouch images in Camera Raw

    This question was posted in response to the following article: http://help.adobe.com/en_US/creativesuite/cs/using/WSB8F2AD18-6EB1-4285-A326-7426B9808E00. html

    Why have you removed all the functionality from the crop tool. I used to size images in Bridge, now to get specific size crops I'd need to go to Photoshop. Adding more resize options to the bottom only affects the whole image, and 100% of finished images I output are cropped,  and obviously not by the same amount, doing any scale to fit at the bottom means differently finished crops. AAAAAR%GH!!!! I have had to revert to CS 6 for workflow. And why has the Output module gone? I used to output different sizes of the same thing for web and print.

  • I am using Aperture 3 to edit RAW and JPEG photo images on my Macbook.  I am having color printing issues with my Canon MP640 Pixma color printer.  The image I see on my macbook is not reciprocated in printing from my printer?

    My issue is that I am not getting print quality compared to the image I see on my screen.  Just recently it has been very wishie washie.  My printer is supposed to be excellent for producing color prints
    I have contacted Canon support but they told me that the signals that are sent to the printer originate from an Apple product, therefore, it is an Apple mac problem not there's.  I am wondering if my on screen proofing and/or printing profiles are correctly set.  I notice that in 'print profiles' there are nine different options for printing from my particular printer.  How confusing is that? 
    I have also found that when I choose a high standard print option my photo print comes out very red. 
    Can some kind person please help me?  I don't seem to be getting any help from anyone else!  Thanks in anticipation.

    You didn't mention any color calibration being done on your monitor.  This is an essential part of any color-correct workflow.  What are you using to calibrate your monitor (and your printer)?
    Print profiles (for soft-proofing as well as printing) are for specific combinations of paper & printer.  The nine you have are each, most likely, for a common paper (perhaps mfr'd by Canon) to be used with your printer.
    I don't know what you mean when you say "I choose a high standard print option".
    Have you read the User Manual chapter on printing?
    Printing Your Images
    There is also a good appendix on calibration:
    Calibrating Your Aperture System

  • When I try and print an "Approach Plate, or Departure" from ForeFlight to my Epson Stylus NX430 using AirPrint the image is resized. How can I print without it resizing. I want to have the plate print in the original size so I can use it.

    When I try and print an "Approach Plate, or Departure" from ForeFlight to my Epson Stylus NX430 using AirPrint the image is resized. How can I print without it resizing. I want to have the plate print in the original size so I can use it. Is this an Apple, Epson, or Foreflight Issue? I just purchased the printer so I can return it and get a different model or brand. I spoke to Epson and the suggestions given did not resolve the issue. I have cut the paper down to the size of the plate roughly 5.5x8 and it still try's to print at 8.5x11. I have also requested help through ForeFlights Tech help but have yet to receive an answer.
    Please help!

    It varies based on what you ordered and whether it is in stock or has to be assenbled and shipped from China. Your email conformation should give an estimate of when the items are expected to be shipped or available for pick up if you are having it sent to a local Apple Store.

Maybe you are looking for