Pivot point in image rotation with JAI...

I'm using JAI to rotate some images...
but it doesnt seem to rotate around the center of the image..
here is my codes..
float xOrigin = ((float)src.getWidth())/2;
float yOrigin = ((float)src.getHeight())/2;
float angle = (float)v * (float)(Math.PI/180.0F);
Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_BICUBIC);
ParameterBlock params = new ParameterBlock();
params.addSource(src);
params.add(xOrigin);
params.add(yOrigin);
params.add(angle); // rotation angle
params.add(interp); // interpolation method
des = JAI.create("rotate", params);
displayImage(des);
note: src and des is defined as PlanarImage.
any clues why the center point isn't height/2 and width/2??
thx

It seems that on problem with the code, I use same code when I rotate the image. How do you display the image? maybe problem is there, after the ratation, the origin of the image changes, if your display method can not handle this, you may not display it properly.

Similar Messages

  • Image rotation with fade effect

    I am new to the spry framework and have just started going
    through the examples to see if I could create an image rotator that
    fades the images into each other when changing. I have taken
    snippets from different places to do this and think I have the
    answer but really wanted some feedback to sanity check and let me
    know if this is the best way of doing it. If it is, then I hope
    others will find it useful.
    Here is the url to the example:
    Image
    rotation example
    And here is the code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN"
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml"
    xmlns:spry="
    http://ns.adobe.com/spry">
    <head>
    <title>Sample Image Rotation</title>
    <meta http-equiv="content-type" content="text/html;
    charset=iso-8859-1" />
    <meta http-equiv="X-UA-Compatible"
    content="IE=7;FF=3;OtherUA=4" />
    <meta name="author" content="www.baytree-cs.com - Peter
    Barkway"/>
    <meta name="copyright" content="(C)2006 Baytree Computer
    Services, All right reserved."/>
    <meta name="abstract" content="ISM Homepage" />
    <meta name="description" content="ISM Homepage" />
    <meta name="keywords" content="ISM Homepage"/>
    <meta name="robots" content="all,index,follow"/>
    <meta name="distribution" content="global"/>
    <meta name="mssmarttagspreventparsing"
    content="true"/>
    <meta name="rating" content="general"/>
    <style type="text/css">
    .element{
    float:left;
    position: relative;
    width: 350px;
    text-align: center;
    #display{
    opacity: 0;
    filter: alpha(opacity=0);
    #animate{
    left: -350px;
    opacity: 1;
    filter: alpha(opacity=100);
    </style>
    </head>
    <body>
    <noscript><h1>This page requires JavaScript.
    Please enable JavaScript in your browser and reload this
    page.</h1></noscript>
    <div id="container">
    <div id="display" class="element"
    spry:detailregion="dsImg"><img src="<?php echo
    $rootDir.$baseDir;?>/{@base}{@path}"/></div>
    <div id="animate" class="element"
    spry:detailregion="dsImg2"><img src="<?php echo
    $rootDir.$baseDir;?>/{@base}{@path}"/></div>
    <p class="clear"></p>
    </div>
    <script type="text/javascript"
    src="js/xpath.js"></script>
    <script type="text/javascript"
    src="js/SpryData.js"></script>
    <script type="text/javascript"
    src="js/SpryEffects.js"></script>
    <script type="text/javascript">
    var dsGalleries = new Spry.Data.XMLDataSet("spry.php",
    "galleries/gallery", { method: "POST", postData:
    "c=1&d=<?php echo $baseDir;?>", headers: {
    "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    var dsImg = new Spry.Data.XMLDataSet("spry.php",
    "gallery/photos/photo", { method: "POST", postData:
    "c=2&d=<?php echo
    $baseDir;?>/{dsGalleries::@base}&s={dsGalleries::sitename}",
    headers: { "Content-Type": "application/x-www-form-urlencoded;
    charset=UTF-8" } });
    var dsImg2 = new Spry.Data.XMLDataSet("spry.php",
    "gallery/photos/photo", { method: "POST", postData:
    "c=2&d=<?php echo
    $baseDir;?>/{dsGalleries::@base}&s={dsGalleries::sitename}",
    headers: { "Content-Type": "application/x-www-form-urlencoded;
    charset=UTF-8" } });
    var imageInterval = 8000; // 8 seconds
    var imageFadeInterval = 4000; // 4 seconds
    var image2Loaded = null;
    var effect = new Spry.Effect.Fade('animate', {from: 100, to:
    0, toggle: true, duration: imageFadeInterval});
    // Prepare an observer that will change the opacity of the
    initially
    // hidden element in oposition with the initially visible
    element
    var obs1 = new Object;
    // On each effect step we calculate the complementary
    opacity for the other image container.
    obs1.onStep = function(ef){
    if (typeof otherEl == 'undefined')
    otherEl = document.getElementById('display');
    var opacity = 0;
    if(/MSIE/.test(navigator.userAgent)){
    opacity = Spry.Effect.getStyleProp(ef.element,
    'filter').replace(/alpha\(opacity([0-9]{1,3})\)/, '$1');
    otherEl.style.filter = "alpha(opacity=" + parseInt(100 * (1
    - opacity), 10) + ")";
    }else{
    opacity = Spry.Effect.getStyleProp(ef.element, 'opacity');
    otherEl.style.opacity = (1 - opacity);
    // Attach the observer to the Fade effect
    effect.addObserver(obs1);
    function fadeInContent() {
    // 1st time in so set the current rows so that the 'animate'
    set is 1 ahead of the 'display' set
    if(image2Loaded == null) {
    dsImg.setCurrentRowNumber((dsImg.getCurrentRowNumber() + 1)
    % dsImg.getData().length);
    dsImg2.setCurrentRowNumber((dsImg.getCurrentRowNumber() + 2)
    % dsImg.getData().length);
    image2Loaded = 0;
    } else {
    if(image2Loaded) {
    dsImg.setCurrentRowNumber((dsImg.getCurrentRowNumber() + 1)
    % dsImg.getData().length);
    image2Loaded = 0;
    } else {
    dsImg2.setCurrentRowNumber((dsImg.getCurrentRowNumber() + 1)
    % dsImg.getData().length);
    image2Loaded = 1;
    effect.start();
    var obs2 = {
    onPostLoad: function() {
    setInterval("fadeInContent()", imageInterval);
    dsImg.addObserver(obs2);
    </script>
    </body>
    </html>

    I think that I might have got this going now. Here is the
    code if anyone wants to use it.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN"
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml"
    xmlns:spry="
    http://ns.adobe.com/spry">
    <head>
    <title>Sample Image Rotation</title>
    <meta http-equiv="content-type" content="text/html;
    charset=iso-8859-1" />
    <meta http-equiv="X-UA-Compatible"
    content="IE=7;FF=3;OtherUA=4" />
    <meta name="author" content="www.baytree-cs.com - Peter
    Barkway"/>
    <meta name="copyright" content="(C)2006 Baytree Computer
    Services, All right reserved."/>
    <meta name="abstract" content="ISM Homepage" />
    <meta name="description" content="ISM Homepage" />
    <meta name="keywords" content="ISM Homepage"/>
    <meta name="robots" content="all,index,follow"/>
    <meta name="distribution" content="global"/>
    <meta name="mssmarttagspreventparsing"
    content="true"/>
    <meta name="rating" content="general"/>
    <style type="text/css">
    .element{
    float:left;
    position: relative;
    width: 350px;
    text-align: center;
    #display{
    opacity: 0;
    filter: alpha(opacity=0);
    #animate{
    left: -350px;
    opacity: 1;
    filter: alpha(opacity=100);
    </style>
    </head>
    <body>
    <noscript><h1>This page requires JavaScript.
    Please enable JavaScript in your browser and reload this
    page.</h1></noscript>
    <div id="container">
    <div id="display" class="element"
    spry:detailregion="dsImg"><img src="<?php echo
    $rootDir.$baseDir;?>/{@path}"/></div>
    <div id="animate" class="element"
    spry:detailregion="dsImg2"><img src="<?php echo
    $rootDir.$baseDir;?>/{@path}"/></div>
    <p class="clear"></p>
    </div>
    <script type="text/javascript"
    src="js/xpath.js"></script>
    <script type="text/javascript"
    src="js/SpryData.js"></script>
    <script type="text/javascript"
    src="js/SpryEffects.js"></script>
    <script type="text/javascript">
    var dsGalleries = new Spry.Data.XMLDataSet("spry.php",
    "galleries/gallery", { method: "POST", postData:
    "c=1&d=<?php echo $baseDir;?>", headers: {
    "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    var dsImg = new Spry.Data.XMLDataSet("spry.php",
    "gallery/photos/photo", { method: "POST", postData:
    "c=2&d=<?php echo
    $baseDir;?>/{dsGalleries::@base}&s={dsGalleries::sitename}",
    headers: { "Content-Type": "application/x-www-form-urlencoded;
    charset=UTF-8" } });
    var dsImg2 = new Spry.Data.XMLDataSet("spry.php",
    "gallery/photos/photo", { method: "POST", postData:
    "c=2&d=<?php echo
    $baseDir;?>/{dsGalleries::@base}&s={dsGalleries::sitename}",
    headers: { "Content-Type": "application/x-www-form-urlencoded;
    charset=UTF-8" } });
    var imageInterval = 4000; // 8 seconds
    var imageFadeInterval = 2000; // 4 seconds
    var effect = new Spry.Effect.Fade('animate', {from: 100, to:
    0, toggle: true, duration: imageFadeInterval});
    // Prepare an observer that will change the opacity of the
    initially
    // hidden element in oposition with the initially visible
    element
    var obs1 = new Object;
    // On each effect step we calculate the complementary
    opacity for the other image container.
    obs1.onStep = function(ef){
    if (typeof otherEl == 'undefined')
    otherEl = document.getElementById('display');
    var opacity = 0;
    if(/MSIE/.test(navigator.userAgent)){
    opacity = Spry.Effect.getStyleProp(ef.element,
    'filter').replace(/alpha\(opacity([0-9]{1,3})\)/, '$1');
    otherEl.style.filter = "alpha(opacity=" + parseInt(100 * (1
    - opacity), 10) + ")";
    }else{
    opacity = Spry.Effect.getStyleProp(ef.element, 'opacity');
    otherEl.style.opacity = (1 - opacity);
    // Attach the observer to the Fade effect
    effect.addObserver(obs1);
    function fadeInContent() {
    // 1st time in so set the current rows so that the 'animate'
    set is 1 ahead of the 'display' set
    //use this flag to avoid the effect running on load
    if (typeof image2Loaded == 'undefined') {
    dsImg.setCurrentRowNumber((dsImg.getCurrentRowNumber() + 1)
    % dsImg.getData().length);
    dsImg2.setCurrentRowNumber((dsImg.getCurrentRowNumber() + 2)
    % dsImg.getData().length);
    var curRow = dsImg.getCurrentRow();
    image2Loaded = 0;
    } else {
    if(image2Loaded) {
    var img = document.getElementById('display');
    dsImg.setCurrentRowNumber((dsImg.getCurrentRowNumber() + 1)
    % dsImg.getData().length);
    var curRow = dsImg.getCurrentRow();
    image2Loaded = 0;
    } else {
    var img = document.getElementById('animate');
    dsImg2.setCurrentRowNumber((dsImg.getCurrentRowNumber() + 1)
    % dsImg.getData().length);
    var curRow = dsImg2.getCurrentRow();
    image2Loaded = 1;
    var imgPath = '<?php echo $rootDir.$baseDir;?>/' +
    curRow["@path"];
    var gImageLoader = new Image();
    gImageLoader.onload = function()
    effect.start();
    gImageLoader.src = imgPath;
    var obs2 = {
    onPostLoad: function() {
    setInterval("fadeInContent()", imageInterval);
    dsImg2.addObserver(obs2);
    </script>
    </body>
    </html>

  • Image Rotation with AE SDK

    Hello all,
       I am wondering if someone could suggest a desription of image rotation using Adobe AE SDK - in a Forum entry or in some other related document. While some elements of rotation may be considered available in SDK sample projects - Shifter for all pixels, CCU for individual pixels manipulation - I will appreciate more details for variable subpixel processing and neighbouring pixel interpolation for variable row-by-row shift. It is assumed the angle of rotation is fixed during the effect, and there are no worries about the appearance of out-of-border picture elements since there is a background. Speed will not be an issue as well.
       Thank you in advance.        

    well, the easiest way for rotating an image through the sdk is by using transform_word().
    it takes a matrix (or matrices for motion blur), so you can do any transform operation concievable via a matrix.
    here's a thread with some detail about this function:
    http://forums.adobe.com/message/1970939#1970939
    as for line by line transformations...
    there are some toos in the SDK, but they're available only for AEPGs of type "artizan" (the plug-ins that render whole comps),
    so if you're planning a layer effect, these tools are out of the question.
    you can do that calculation manually in a few ways.
    you can create a tranformation matrix and run each pixel through it, which would probably be the fastest most versitile way.
    or you can use trigonometry, which would probably be the easiest to implement but the slowest to process.
    using the sdk's subpixel sample functions would complete the tools you need, but keep in mind that this would be the slowest possible way of rotating an image.

  • How to use Image Rotator with Firefox??

    Since the latest update of Firefox , my image Rotator will not show my images in my forum. They work fine if I use IE but I much prefer to use Firefox as my browser.
    IPlease help, I don't want to use IE.
    Thanks in advance.

    Make use of Firefox Addons
    *https://addons.mozilla.org/en-us/firefox/addon/rotate-image/

  • Adding private IFD and IFD pointer to TIFF image metadata with jai-imageio

    Hi,
    I searched on the Internet for the answer but I was only able to find this post from the old forum/mailing list:
    http://www.java.net/node/698039
    The question in the post went unanswered and I am in a very similar situation now. To re-iterate the questions:
    * How to merge the metadata of the private IFD into the root IFD?
    * What to populate for the offset parameter in the private IFD pointer tag (the parent tag)?
    I am modeling it after the EXIF tag sets, very similar to what is in the above link.
    Any help would be greatly appreciated ...
    Thanks,
    Dennis

    Hi Jim,
    Thank you for posting in the MSDN forum.
    You know that this forum is to discuss the VS IDE issue,
    I am afraid that the issue is out of support of
    Visual Studio General Forum
    To help you find the correct forum, would you mind letting us know more information about this issue? Which kind of app do you want to develop, a WPF app or others?
    If it is the WPF app, maybe this forum would be better for it:     
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wpf
    Thanks for your understanding.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • Correct image rotation with CameraRoll

    At the moment I'm implementing CameraRoll in my app.
    It's a great class, but the images do not rotate correctly on Android. Other apps seem to be able to determine if the picture was taken in landscape or portrait mode, and view the image in the correct orientation.
    As for now the users in my app will have to rotate their image manually...
    Does anyone know a fix/workaround for this?

    well, the easiest way for rotating an image through the sdk is by using transform_word().
    it takes a matrix (or matrices for motion blur), so you can do any transform operation concievable via a matrix.
    here's a thread with some detail about this function:
    http://forums.adobe.com/message/1970939#1970939
    as for line by line transformations...
    there are some toos in the SDK, but they're available only for AEPGs of type "artizan" (the plug-ins that render whole comps),
    so if you're planning a layer effect, these tools are out of the question.
    you can do that calculation manually in a few ways.
    you can create a tranformation matrix and run each pixel through it, which would probably be the fastest most versitile way.
    or you can use trigonometry, which would probably be the easiest to implement but the slowest to process.
    using the sdk's subpixel sample functions would complete the tools you need, but keep in mind that this would be the slowest possible way of rotating an image.

  • Image rotation with spry

    <cfsetting enableCFoutputOnly="yes"
    showDebugOutput="no">
    <cfinclude
    template="../includes/XMLExport/XMLExport.cfm">
    <cfquery name="get_ads" datasource="#dns#">
    SELECT *
    FROM BannerAds
    WHERE type = 'c' AND
    realastate = 3 AND
    active = 1
    </cfquery>
    <cfscript>
    // Begin XMLExport get_ads
    xmlExportObj = XMLExport_CreateObject("XMLExport");
    xmlExportObj.init();
    xmlExportObj.setRecordset(get_ads);
    xmlExportObj.addColumn("ID", "ID");
    xmlExportObj.addColumn("type", "type");
    xmlExportObj.addColumn("fileName", "fileName");
    xmlExportObj.addColumn("link", "link");
    xmlExportObj.addColumn("date", "date");
    xmlExportObj.addColumn("realastate", "realastate");
    xmlExportObj.addColumn("rotation", "rotation");
    xmlExportObj.addColumn("active", "active");
    xmlExportObj.setMaxRecords("ALL");
    xmlExportObj.setXMLEncoding("ISO-8859-1");
    xmlExportObj.setXMLFormat("NODES");
    xmlExportObj.setRootNode("id");
    xmlExportObj.Execute();
    // End XMLExport get_ads
    </cfscript>
    <cfsetting enableCFoutputOnly="no">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    </body>
    </html>
    Which I get my results of.....

    <id>

    <row>
    <ID>78</ID>
    <type>c</type>
    <fileName>CDCLarue-Column.gif</fileName>
    <link>
    http://www.cdclarue.com/cd.php</link>
    <date>2007-25-04 08:53:00</date>
    <realastate>3</realastate>
    <rotation/>
    <active>1</active>
    </row>

    <row>
    <ID>80</ID>
    <type>c</type>
    <fileName>Werk-column.jpg</fileName>
    <link>
    http://www.werkmaster.com/</link>
    <date>2007-01-05 13:30:00</date>
    <realastate>3</realastate>
    <rotation/>
    <active>1</active>
    </row>

    <row>
    <ID>85</ID>
    <type>c</type>
    <fileName>Versatile-column.gif</fileName>
    <link>
    http://www.garagecoatings.com/</link>
    <date>2007-15-05 14:00:00</date>
    <realastate>3</realastate>
    <rotation/>
    <active>1</active>
    </row>
    </id>
    Ok.....I'm obviously new to Spry-Ajax :) but have learned a
    lot already I just need to understand how to work with the data in
    the <body> area... I basically need to pull each image or set
    of data individually and rotate each data set/image on the page at
    10 second intervals.
    Thank you,
    Brian

    <cfsetting enableCFoutputOnly="yes"
    showDebugOutput="no">
    <cfinclude
    template="../includes/XMLExport/XMLExport.cfm">
    <cfquery name="get_ads" datasource="#dns#">
    SELECT *
    FROM BannerAds
    WHERE type = 'c' AND
    realastate = 3 AND
    active = 1
    </cfquery>
    <cfscript>
    // Begin XMLExport get_ads
    xmlExportObj = XMLExport_CreateObject("XMLExport");
    xmlExportObj.init();
    xmlExportObj.setRecordset(get_ads);
    xmlExportObj.addColumn("ID", "ID");
    xmlExportObj.addColumn("type", "type");
    xmlExportObj.addColumn("fileName", "fileName");
    xmlExportObj.addColumn("link", "link");
    xmlExportObj.addColumn("date", "date");
    xmlExportObj.addColumn("realastate", "realastate");
    xmlExportObj.addColumn("rotation", "rotation");
    xmlExportObj.addColumn("active", "active");
    xmlExportObj.setMaxRecords("ALL");
    xmlExportObj.setXMLEncoding("ISO-8859-1");
    xmlExportObj.setXMLFormat("NODES");
    xmlExportObj.setRootNode("id");
    xmlExportObj.Execute();
    // End XMLExport get_ads
    </cfscript>
    <cfsetting enableCFoutputOnly="no">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    </body>
    </html>
    Which I get my results of.....

    <id>

    <row>
    <ID>78</ID>
    <type>c</type>
    <fileName>CDCLarue-Column.gif</fileName>
    <link>
    http://www.cdclarue.com/cd.php</link>
    <date>2007-25-04 08:53:00</date>
    <realastate>3</realastate>
    <rotation/>
    <active>1</active>
    </row>

    <row>
    <ID>80</ID>
    <type>c</type>
    <fileName>Werk-column.jpg</fileName>
    <link>
    http://www.werkmaster.com/</link>
    <date>2007-01-05 13:30:00</date>
    <realastate>3</realastate>
    <rotation/>
    <active>1</active>
    </row>

    <row>
    <ID>85</ID>
    <type>c</type>
    <fileName>Versatile-column.gif</fileName>
    <link>
    http://www.garagecoatings.com/</link>
    <date>2007-15-05 14:00:00</date>
    <realastate>3</realastate>
    <rotation/>
    <active>1</active>
    </row>
    </id>
    Ok.....I'm obviously new to Spry-Ajax :) but have learned a
    lot already I just need to understand how to work with the data in
    the <body> area... I basically need to pull each image or set
    of data individually and rotate each data set/image on the page at
    10 second intervals.
    Thank you,
    Brian

  • Capture Image metadata with JAI

    Hi,
    Can we capture the metadata of a photograph taken by a digital camera (JPEG file) using the JAI?
    Some of the features that I'm interested in capturing are: Data Picture Taken, Camera Model and so on.
    Any sample snippet of code is highly appreciated.
    Thanks,
    Bhaskar

    Should have searched the forum throughly....this is the code which was given by Mr. Maxideon [http://forums.sun.com/profile.jspa?userID=1078315] -- All credits to him -- although this post is very old, probably would be helpful for someone else :)
    import javax.swing.*;
    import javax.imageio.*;
    import javax.imageio.metadata.*;
    import javax.imageio.stream.ImageInputStream;
    import javax.imageio.stream.MemoryCacheImageInputStream;
    import org.w3c.dom.NodeList;
    public class ExifSSCCE {
        private static String JPEGMetaFormat = "javax_imageio_jpeg_image_1.0";
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    try{
                        runSequence();
                    }catch(Exception e) {
                       e.printStackTrace();
                       System.exit(-1);
        private static void showMessageAndExit(String message) {
            JOptionPane.showMessageDialog(null,message,"Error",JOptionPane.ERROR_MESSAGE);
            System.exit(0);
        public static void runSequence() throws java.io.IOException{
            if(!ImageIO.getImageReadersByFormatName("tif").hasNext()) {
                showMessageAndExit("You will need a tiff ImageReader plugin to " +
                        "parse exif data.  Please download \"JAI-ImageIO\".");
            JOptionPane.showMessageDialog(null,"Please select a jpeg file with " +
                    "EXIF metadata");
            JFileChooser chooser = new JFileChooser();
            if(chooser.showOpenDialog(chooser) == JFileChooser.CANCEL_OPTION) {
                System.exit(0);
            java.io.File toOpen = chooser.getSelectedFile();
            ImageInputStream in = ImageIO.createImageInputStream(toOpen);
            java.util.Iterator<ImageReader> readers = ImageIO.getImageReaders(in);
            if(!readers.hasNext()) {
                showMessageAndExit("The selected file was not an image file, or " +
                        "not a type that ImageIO recognized.");
            ImageReader reader = null;
            while(readers.hasNext()) {
                ImageReader tmp = readers.next();
                if(JPEGMetaFormat.equals(tmp.getOriginatingProvider().getNativeImageMetadataFormatName())) {
                    reader = tmp;
                    break;
            if(reader == null) {
                showMessageAndExit("The selected file was not a jpeg file.");
            reader.setInput(in, true, false);
            byte[] exifRAW = getEXIF(reader.getImageMetadata(0));
            if(exifRAW == null) {
                showMessageAndExit("The selected jpeg file did not contain any " +
                        "exif data.");
            reader.dispose();
            in.close();
            IIOMetadata exifMeta = getTiffMetaFromEXIF(exifRAW);
            JFrame frame = new JFrame();
            frame.setContentPane(new JScrollPane(parseExifMeta(exifMeta)));
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
        private static JTable parseExifMeta(IIOMetadata exifMeta) {
            //Specification of "com_sun_media_imageio_plugins_tiff_image_1.0"
            //http://download.java.net/media/jai-imageio/javadoc/1.1/com/sun/media/imageio/plugins/tiff/package-summary.html
            javax.swing.table.DefaultTableModel tags =
                    new javax.swing.table.DefaultTableModel();
            tags.addColumn("Tag #");
            tags.addColumn("Name");
            tags.addColumn("Value(s)");
            IIOMetadataNode root = (IIOMetadataNode)
                    exifMeta.getAsTree("com_sun_media_imageio_plugins_tiff_image_1.0");
            NodeList imageDirectories = root.getElementsByTagName("TIFFIFD");
            for(int i = 0; i < imageDirectories.getLength(); i++) {
                IIOMetadataNode directory = (IIOMetadataNode) imageDirectories.item(i);
                NodeList tiffTags = directory.getElementsByTagName("TIFFField");
                for(int j = 0; j < tiffTags.getLength(); j++) {
                    IIOMetadataNode tag = (IIOMetadataNode) tiffTags.item(j);
                    String tagNumber = tag.getAttribute("number");
                    String tagName   = tag.getAttribute("name");
                    String tagValue;
                    StringBuilder tmp = new StringBuilder();
                    IIOMetadataNode values = (IIOMetadataNode) tag.getFirstChild();
                    if("TIFFUndefined".equals(values.getNodeName())) {
                        tmp.append(values.getAttribute("value"));
                    }else {
                        NodeList tiffNumbers = values.getChildNodes();
                        for(int k = 0; k < tiffNumbers.getLength(); k++) {
                            tmp.append(((IIOMetadataNode) tiffNumbers.item(k)).getAttribute("value"));
                            tmp.append(",");
                        tmp.deleteCharAt(tmp.length()-1);
                    tagValue = tmp.toString();
                    tags.addRow(new String[]{tagNumber,tagName,tagValue});
            return new JTable(tags);
        /**Returns the EXIF information from the given metadata if present.  The
         * metadata is assumed to be in <pre>javax_imageio_jpeg_image_1.0</pre> format.
         * If EXIF information was not present then null is returned.*/
        public static byte[] getEXIF(IIOMetadata meta) {
            //http://java.sun.com/javase/6/docs/api/javax/imageio/metadata/doc-files/jpeg_metadata.html
            //javax_imageio_jpeg_image_1.0
            //-->markerSequence
            //---->unknown (attribute: "MarkerTag" val: 225 (for exif))
            IIOMetadataNode root = (IIOMetadataNode) meta.getAsTree(JPEGMetaFormat);
            IIOMetadataNode markerSeq = (IIOMetadataNode)
                    root.getElementsByTagName("markerSequence").item(0);
            NodeList unkowns = markerSeq.getElementsByTagName("unknown");
            for(int i = 0; i < unkowns.getLength(); i++) {
                IIOMetadataNode marker = (IIOMetadataNode) unkowns.item(i);
                if("225".equals(marker.getAttribute("MarkerTag"))) {
                    return (byte[]) marker.getUserObject();
            return null;
        /**Uses a TIFFImageReader plugin to parse the given exif data into tiff
         * tags.  The returned IIOMetadata is in whatever format the tiff ImageIO
         * plugin uses.  If there is no tiff plugin, then this method returns null.*/
        public static IIOMetadata getTiffMetaFromEXIF(byte[] exif) {
            java.util.Iterator<ImageReader> readers =
                    ImageIO.getImageReadersByFormatName("tif");
            ImageReader reader;
            if(!readers.hasNext()) {
                return null;
            }else {
                reader = readers.next();
            //skip the 6 byte exif header
            ImageInputStream wrapper = new MemoryCacheImageInputStream(
                    new java.io.ByteArrayInputStream(exif,6,exif.length-6));
            reader.setInput(wrapper,true,false);
            IIOMetadata exifMeta;
            try {
                exifMeta = reader.getImageMetadata(0);
            }catch(Exception e) {
                //shouldn't happen
                throw new Error(e);
            reader.dispose();
            return exifMeta;
    }Edited by: amitahire on Mar 27, 2010 4:57 AM

  • Pivot point in Photoshop CS 4

    Hello
    I seem to have an issue using 3D layers in Photoshop CS 4 ext.
    You see I have a layer which I convert to a 3D layer and I want to rotate the element however I would like to move the pivot point which it rotates from. I am unable to do this. I can not find the pivot point and I am not sure how PS generates the coordinates of the pivot point. This should be a simple task.
    Thanks
    Cheers
    S.

    Hello Bart
    Im not sure how your pulling this off. Could you please provide me with acurate step by step on how you are able to do this? cause I am still not able to get a pivot point from a 3D layer.
    Thanks
    cheers
    stephan

  • Loss of sharpness upon image rotation: Aperture vs. other software

    I have carefully studied the resulting loss of sharpness upon rotation/straightening of images. This topic does not apply to 90/180 degree rotations.
    When any image is rotated (be it JPEG or uncompressed), there will be a slight loss of quality (seen as a loss of sharpness) due to interpolation. The method of interpolation applied will affect the degree of quality degradation.
    Simply put, professional applications such as Adobe Photoshop and even Adobe Lightroom use superior interpolation methods when performing rotations (and who knows, perhaps for other transformations/scalings also?!). Apple Aperture, on the other hand, uses an interpolation method that renders a loss of image sharpness on par with inferior consumer-level software such as Google Picasa or iView Media Pro. Yes, folks, here's a clear reason to select Adobe Lightroom over Apple Aperture.
    Please take a close look at the comparison yourself:
    http://web.mac.com/rishisanyal/iWeb/Homepage/Sharpness.jpg
    Make sure you are viewing the image I have posted at 100%, not scaled, in order to clearly see the inferior quality of images rotated with Aperture & Picasa.
    Apple needs to address this problem by implementing a better interpolation algorithm with its straighten tool. It is sad that we are using and paying for a 'Professional' application that yields results on par with FREE software such as Google Picasa.
    As much as I like Aperture for its other features/integration into Mac OS X, I am switching to Lightroom as of now. Straightening/rotating images is an absolute must, used by every photographer on a daily basis. The loss of image quality, therefore, is unacceptable.
    Please post to this thread if you have experienced the same problem or are simply concerned over this. The more people that show concern, hopefully, the more likely Apple is willing to do something about this ASAP.

    Surely any rotation (apart from the 90/180/270 ones) is by-definition a smoothing operation ? You have to take the values from adjacent pixels and combine them based on the rotation, then average (or use a point-spread function) them to rescale the values back into range.
    Looks to me as though the Adobe products are just applying a sharpen operation immediately after the rotation, whereas Aperture isn't. Or Aperture could be using a simple average of the values, where Adobe is doing a gaussian summation-of-components or something similar.
    My guess would be that they "do a quick sharpen", otherwise it would take longer to do the rotate. The only way you'll ever know is if the developers tell you though...
    -=C=-

  • How can i rotate an image by a pivot point?

    Hello,
    i have a problem, the Imaq Rotate VI only rotate an image by its center. My problem is i need to do this by a known pivot point. How can i achieve this?
    Thank you,
    Francesco.
    Solved!
    Go to Solution.

    can this post help?
    http://forums.ni.com/t5/LabVIEW/Rotate-an-Image-by-specified-pixel/td-p/2570453
    Thanks
    uday,
    Please Mark the solution as accepted if your problem is solved and help author by clicking on kudoes
    Certified LabVIEW Associate Developer (CLAD) Using LV13

  • Pivot Point in "Rotate 3D"

    hi all,
    is there a way to change the pivot point in "rotate 3d" (timlines/add action)?
    i have no problems to set a new pivot point with the transform/rotate tool. works well.
    but in rotate 3d it rotates around the center of the object.
    an example, think of a picture that rotates around a pole.
    have a creative day

    Thank you for the reply.
    Unfortunately it doesn't answer my question.
    I DONT want to animate rotating around the center. I have offset the pivot of an object and rotated around that from state 1 to state 2. But the animation interpilation ignores this and still rotates around the center of the object to get from state 1 to 2.
    I want the object to swing in to the canvas from its bottom corner but I can't get it to honor where I put the pivot during the actual build of animation.
    I am beyond frustrated with the limitations of Catalyst. If I have to go to Flash Builder to add any type of specific function, whats the point, as FB
    is 10 times more complex to me than Flash ever was. The reason I am not messing with Flash is that I don't want to screw with code.
    but I guess I might as well just stick with Flash as in Catalyst
    I can't
    Use Gifs
    Animate around a changed pivot
    Scale a bitmap thats a button (come on really...)
    Unreliable results with swf files that have multiple bitmap images in them.
    Any type of slightly advance animation, such as ...move a background around to loop,  when I am in a static state.

  • Rotate Image Created with createImage() ?

    I've been looking around online for a way to do this, but so far the only things I have found are 50+ lines of code. Surely there is a simple way to rotate an image created with the createImage() function?
    Here's some example code with all the tedious stuff already written. Can someone show me a simple way to rotate my image?
    import java.net.*;
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class RotImg extends JApplet implements MouseListener {
              URL base;
              MediaTracker mt;
              Image myimg;
         public void init() {
              try{ mt = new MediaTracker(this);
                   base = getCodeBase(); }
              catch(Exception ex){}
              myimg = getImage(base, "myimg.gif");
              mt.addImage(myimg, 1);
              try{ mt.waitForAll(); }
              catch(Exception ex){}
              this.addMouseListener(this);
         public void paint(Graphics g){
              super.paint(g);
              Graphics2D g2 = (Graphics2D) g;
              g2.drawImage(myimg, 20, 20, this);
         public void mouseClicked(MouseEvent e){
              //***** SOME CODE HERE *****//
              // Rotate myimg by 5 degrees
              //******** END CODE ********//
              repaint();
         public void mouseEntered(MouseEvent e){}
         public void mouseExited(MouseEvent e){}
         public void mousePressed(MouseEvent e){}
         public void mouseReleased(MouseEvent e){}
    }Thanks very much for your help!
    null

    //  <applet code="RotationApplet" width="400" height="400"></applet>
    //  use: >appletviewer RotationApplet.java
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.AffineTransform;
    import java.awt.image.BufferedImage;
    import javax.swing.*;
    public class RotationApplet extends JApplet {
        RotationAppletPanel rotationPanel;
        public void init() {
            Image image = loadImage();
            rotationPanel = new RotationAppletPanel(image);
            setLayout(new BorderLayout());
            getContentPane().add(rotationPanel);
        private Image loadImage() {
            String path = "images/cougar.jpg";
            Image image = getImage(getCodeBase(), path);
            MediaTracker mt = new MediaTracker(this);
            mt.addImage(image, 0);
            try {
                mt.waitForID(0);
            } catch(InterruptedException e) {
                System.out.println("loading interrupted");
            return image;
    class RotationAppletPanel extends JPanel {
        BufferedImage image;
        double theta = 0;
        final double thetaInc = Math.toRadians(5.0);
        public RotationAppletPanel(Image img) {
            image = convert(img);
            addMouseListener(ml);
        public void rotate() {
            theta += thetaInc;
            repaint();
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                RenderingHints.VALUE_INTERPOLATION_BICUBIC);
            double x = (getWidth() - image.getWidth())/2;
            double y = (getHeight() - image.getHeight())/2;
            AffineTransform at = AffineTransform.getTranslateInstance(x,y);
            at.rotate(theta, image.getWidth()/2, image.getHeight()/2);
            g2.drawRenderedImage(image, at);
        private BufferedImage convert(Image src) {
            int w = src.getWidth(this);
            int h = src.getHeight(this);
            int type = BufferedImage.TYPE_INT_RGB; // options
            BufferedImage dest = new BufferedImage(w,h,type);
            Graphics2D g2 = dest.createGraphics();
            g2.drawImage(src,0,0,this);
            g2.dispose();
            return dest;
        private MouseListener ml = new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                rotate();
    }

  • Rotating image loaded with CameraRoll

    I'm having trouble working out how to rotate an image loaded using CameraRoll on an AIR for iOS app.
    This code below works fine (displayImage() is called when CameraRolls media event returns completed, and imageArea is the scrollPane where the image is shown.
         function displayImage():void
         var image:Bitmap = Bitmap(imageLoader.content);
         imageArea.source = image;
    The image loads just fine untill I try to rotate it:
         function readMediaData():void
         var image:Bitmap = Bitmap(imageLoader.content);
         var imX:int = image.width;
         var imY:int = image.height;
              if (imX>imY)
                  image.rotation = 90;
         imageArea.source = image;
    With the second version the image seems to load because the scroll bars expand to the size of the image I choose, but I don't see anything on the stage.
    What am I doing wrong?
    Any suggestions would be really appreciated.

    I added the new width back to images x position but no joy; no matter what x & y I set the image to, it cannot be seen. The scroll bars expand exactly the right amount for the 'invisible' image, regardless of it's x & y positions as well (you'd think if the image was out of the scrollPane the bars wouldn't adjust like that. I'm not doing something right.
    I'm stumped on this but I'll keep trying things. Thanks for your help and the lead, I appreciate it and it may be part of the problem, but there seems to be a different problem as well.

  • How do I get the rotate tool to default locate the pivot point in the exact center of an object or group of objects?

    My new copy of CC has the default pivot point set to one side, rather than the center. I know I can manually move the pivot point around, but this is not always exact. Is there a way to have AI determine the exact center and then make this the default?

    s,
    We are not talking about the Reference Points in the Transform palette, are we?
    In any case, you may consider the list.
    The following is a general list of things you may try when the issue is not in a specific file, and when it is not caused by issues with opening a file from external media. You may have tried/done some of them already; 1) and 2) are the easy ones for temporary strangenesses, and 3) and 4) are specifically aimed at possibly corrupt preferences); 5) is a list in itself, and 6) is the last resort.
    If possible/applicable, you should save current artwork first, of course.
    1) Close down Illy and open again;
    2) Restart the computer (you may do that up to at least 5 times);
    3) Close down Illy and press Ctrl+Alt+Shift/Cmd+Option+Shift during startup (easy but irreversible);
    4) Move the folder (follow the link with that name) with Illy closed (more tedious but also more thorough and reversible), for CS3 - CC you may find the folder here:
    https://helpx.adobe.com/illustrator/kb/preference-file-location-illustrator.html
    5) Look through and try out the relevant among the Other options (follow the link with that name, Item 7) is a list of usual suspects among other applications that may disturb and confuse Illy, Item 15) applies to CC, CS6, and maybe CS5);
    Even more seriously, you may:
    6) Uninstall (ticking the box to delete the preferences), run the Cleaner Tool (if you have CS3/CS4/CS5/CS6/CC), and reinstall.
    http://www.adobe.com/support/contact/cscleanertool.html

Maybe you are looking for

  • HT5205 I am roaming but cannot connect to the internet?

    I am roaming with my iPad, but cannot connect to the internet?

  • Oc4j server embeded in Jdeveloper 10g is not ruuning

    hi, 1. I am trying to run ocrj server embede in Jdeveloper from command promt for which as given step in Jdevelioper handbook , i proceeded as executing setvars -go from directory jdev\bin , but i am getting the following error D:\JDev\jdev\bin>setva

  • ORDER BY from itab fields

    Hi, is there a possibility to order data of a select statement by contents of an itab? The order criteria of the itab are dynamic thus I cannot hard code them. Example: (lt_order_criteria is actually an imported table) I basically want to order by io

  • Itunes 10 what did I do wrong ??

    okay this is long but stay with me if you can help... I had itunes 9 working fine on my PC, all the media was on D: drive (but not in the itunes standardized folders structure).. as well as a backup of all the "itunes" account folders.. I have one 'a

  • Compatibility Mac's and Blackberry's - Issues?

    I am not sure if this should be posted in the iSync or Mac OS X v10.5 section. So forgiven me if I have posted it in the wrong spot. I am thinking of getting a Blackberry Phone (Because a lot of my business customers use them and would like faster re