Scaling images dynamically

i'm loading images dynamically. The images that will be
uploaded will very rarely be of the exact same dimensions, so
scaling percent wise doesn't exactly do what I want. I would like
to scale an image up and down to a precise amount of pixels (say,
116(width)*86(height)).

once the image is loaded completely (onLoadInit Event must be
fired if using MovieClipLoader) you can access the size of the
image via the _width and _height properties.
The logic to code would be to check the size of the image and
check if it fits into a virtual bounding box that marks the max
width and height for the images as they should be dispayed.
If one (or both) sides of the image exceeds the maximum
width, calculate the percentage by which you must scale the image
down to fit this sied into the "box". Apply this factor to BOTH the
widht and the height, then check if the other side of the image is
still to big to fit into the box and repeat the downscaling if
needed.

Similar Messages

  • Resizing/scaling images

    Hi All,
              I am integrating Google Maps using BSP..  I have custom icons being displayed on the map as markers. I have a requirement where in this marker has to be scalable. Scaling/resizing images is possible using Vector Images using Walter Zorn Java scripts http://www.walterzorn.com/dragdrop/dragdrop_e.htm . But its getting complex as I have dynamic images and numerous images to be placed.. Can this be done in my scenario?
    Is there any other option for scaling / resizing images dynamically?

    Hi,
    the simpliest is to use a javascript framework like jquery plus a crooesponding plugin like imagefit.
    Check out google via 'jquery scale images'.
    Best regards, Stefan

  • How to change the images dynamically in a table.

    Hai,
                     How to change the images dynamically in a table based on the condition in webdynpro abap.
    Edited by: Ravi.Seela on Oct 13, 2011 2:17 PM

    This has been much discussed earlier. Do search posts.
    For your scenario i would do the following.
    inside your node which is binded to the table, i create a new node image with cardinality 1 ..1 and a attribute called path of type string.
    create a  supply function for the node image .
    Supply method now has a Element (Parent element ) and node.
    Based on your record in element, set the right image source to path attribute and bind the node.
    This will make sure that the framework calls the image supply function for every row in a table.

  • Adobe form - Printing images dynamically

    I have created a simple read-only (not interactive) Adobe form. At the end of the document, I need to print a signature depending upon the approver (which I can access from the data structure imported into the form.).
    If I create an image field, how do I assign the image dynamically depending on the approver?
    I have thought of an alternative solution of creating 3 separate forms each with a static image of the signature and calling a separate form in the program depending on the approver. But I was wondering if I can assign images dynamically so that I can have only one form.
    Any help will be greatly appreciated.
    Jitendra Mehta

    Hello . The solution is easy, I have posted the solution into IFbA forum under NeWeaver many times. And I can recommend you to read this article where there is a complete solution for your problem:
    http://www.docstoc.com/docs/2540673/How-To-Integrate-ADOBE-form-on-WebdynPro-for-ABAP-and-Deploy-it-
    It was originally SAP SDN blog, but I am not able to locate it on sap site any more. Hope this solves your problem, regards Otto

  • Proble displaying images dynamically in jsp

    Hi, I am new here. I have to display the images dynamically reading from a database. I have no problem displaying images. When i try to reduce the width in img tag then it is slowly rendering it. How to overcome this.
    <img src="image.jsp?imgID=112" width="150" heigth="130" border="0">
    I am also giving the sample jsp to display
         byte [] imgData = blob.getBytes(1,(int)blob.length());
    response.setContentType("image/jpeg");
    OutputStream o = response.getOutputStream();
    o.write(imgData);
    I want to display the image without any time taken. How could I solve this. Please Help me.
    Thanks.
    Phani.

    You should not crosspost questions. It is rude and a waste of our time.
    Please stick to one topic: [http://forums.sun.com/thread.jspa?threadID=5372144].

  • How to add Image dynamically in Webdynpro ABAP

    Hi Experts,
    How to add Image dynamically in Webdynpro ABAP.
    My requirement is i maintain all the images in a table.
    image source has to pick the table URl dynamically and display.
    is that possible in webdynpro?
    and also please give the suggesion,
    without using MIME objects is that anyway to get images?
    Thanks in advance.
    Regrads,
    Jeyanthi

    Hi,
      are those icons wou want to display then. he following code will be useful.
    data : lo_IMG type ref to CL_WD_IMAGE.
    LO_IMG = cl_wd_IMAGE=>new_IMAGE( id = img_id SOURCE = 'ICON_BW_APD_TARGET' tooltip = sts_tltp ).
    lo_cont->add_child( the_child = lo_img ).
    here lo_cont is the container where you want to add the image dynamically and source is the attribiute through which you can change the ICON image. this thing you can getit from data base table and change accordingly.
    Regards,
    Anil kumar G

  • Scaled image doesn't appear

    Hi, can someone tell me why the scaling of the image does not work in the code below.
    I making a board game application with these inherited JLabel components used to display each players piece on a background created using an inherited JPanel. The image is correctly displayed on the JPanel at the correct location.
    The problem I'm encountering is that when I attempt to scale the image used the scaledInstance method it doesn't appear on the board but appears perfectly if I use the default image (comment out the scaled instance part of the line).
    I've tried downscaling as well increasing size, in case the image is too large and putting absolute values in but to no avail.
    Any help would be appreciated.
    Thanks
    package UserInterface;
    import java.awt.*;
    import javax.swing.*;
    public class PieceIcon extends JLabel
        //Create new image with the piece (symbol) chosen by the player
        public PieceIcon(String symbol,int pNum)
            playerNumber = pNum;
         pieceImage = new ImageIcon("./Images/"+symbol+".jpg").getImage().getScaledInstance(10,10,Image.SCALE_DEFAULT);
            // above line works if scaled instance part removed, even though scaled image smaller
            setOpaque(false);
        public void paintComponent(Graphics g)
           super.paintComponent(g);
           g.drawImage(pieceImage,boardPos[0][(MainFrame.getPlayer(playerNumber).getCurrentBoardPos())],
                                  boardPos[1][(MainFrame.getPlayer(playerNumber).getCurrentBoardPos())],this);
        private Image pieceImage;
        private int playerNumber;
        private static int[][] boardPos = (set of relative positions here, not displayed to make post easier to read)

    bump

  • How to render image dynamically in ADF using URL

    Hi all,
    I have a requirement where i need to render the images dynamically using the url. As the url are of the IPM Application and each of the url is associated to a particular image of a particular document. I have tried making the URL Data Control but couldn't able to get the Image as per the document,even the image is not being rendered onto the page.I want the whole IPM console to be rendered on my jspx page.
    Note- It is not a wsdl url.
    Please suggest how should i implement this
    thanks in advance

    if you decompile the imaging.ear file, there is a web.xml file which you can add the following parameter:
    <context-param>
    <param-name>oracle.adf.view.rich.security.FRAME_BUSTING</param-name>
    <param-value>never</param-value>
    </context-param>
    or take a look at      Receiving "Warning: Unable to load content in a frame. Frame content will load at the top level." When Trying to Use the <af:inlineFrame> Component [ID 1266770.1] on Oracle Support.
    Make sure you take a copy of the imaging app before you make changes. You can then upload back through the weblogic console.
    Sudi

  • How to change the image dynamically depend upon the input parameter

    Hi All
    I have one report running depend upon the Organization specific, I have 15 operating unit and 15 different logo for each operating unit.
    How to change the Logo dynamically depend upon the input passed by the user.
    If I have three or four logo i can add in my layout using if else statement and its works fine but i have more that 10 logos so its no possible to keep these in My RTF Template.
    Is it possible to change the logo according to the input without keeping this in Template.
    I have seen this link but its not working fine
    http://erpschools.com/articles/display-and-change-images-dynamically-in-xml-publisher
    Regards
    Srikkanth.M

    Hi,
    I have not completed fully,so sorry i cant able to share the files, could you please give me some tips and steps to do.
    Without having the logo in RTF if it possible to bring the logo depends on the user input (Ie Operating unit).
    Regards
    Srikkanth

  • Scaling image files for Slide presentation in Keynote

    I have had great problems importing and scaling images for Keynote presentations with approx 500+ images. Having tried to adjust the image to fit the full screen the scaling results in unacceptable pixelation. I seem to have solved this now by batch processing my image files and saving them as PDF files. These are then imported from the Aperture Library as iPhoto wont recognise the PDF file format!
    It's a pity that Keynote has so many restrictions for use in Slide/music presentations, having seen incredible professional results with Pic2exe (which unfortunately at present is not available in Mac format - tho the Win exe file will run I am told).

    Please tell us what you are really trying to do!!
    You know like dumb stuff like where are the images from? What's their resolution? If you';re using Aperture you can't be a newbie. 
    You can achieve incredible professional results in Keynote, but you need to know how it wants to work.
    Kelly is right. This is not just a ***** session but a place to get real help from real people.
    Silly things like Image Placeholders will make your life much simpler. etc.

  • Black background when scaling images with transparent background

    I am implementing Zooming functionality for reports which have some icons. I am trying to scale icon by scaling its image. But the problem I am facing is that the icons have transparent background and the scaling puts a black background in place of transparent. Is there any way to maintain its transparency or better yet, Is there anyway to put a white backgound instead of the black one that is created by default ? Here is my code
         public static Icon getScaledIcon(Icon icon){
             if(icon instanceof ImageIcon){
                  Image outImage = ((ImageIcon)icon).getImage();
                      return new ImageIcon(getScaledImage(outImage));
             }else{
                  Image outImage = new BufferedImage(icon.getIconWidth(),
                            icon.getIconHeight(),
                            BufferedImage.TYPE_INT_ARGB);
                    JComponent comp = new JComponent(){};
                    icon.paintIcon(comp, outImage.getGraphics(), 0, 0);
                    return new ImageIcon(getScaledImage(outImage));
        public static Image getScaledImage(Image image){
             image = image.getScaledInstance((int)(image.getWidth(null) * getScale()),
                           (int)(image.getHeight(null) * getScale()), Image.SCALE_SMOOTH);
            return image;
        }I haven't done much image manipulation , so I would really appreciate any help or advice.

    I have also not done much of image work. But I guess you could achieve your functionality of showing scaled image in the screen by not scaling the image and show it, instead scale the image in paint method by calling g.drawImage giving the height and width. But use high resolution images so that scaling is good.
    If you do in this manner, you could give any colour you want as background to fill the transparent area or leave it as such.
    Regards,
    techece.

  • Is this a way of scaling images?

    Hi,
    I've got a few questions regarding image scaling and need some advices on whether my method is correct or to throw away as quickly as possible...
    I've defined all my website images in "ems" so that they rescale when the user zooms in/out the page or decreases/increases the font. I thought this would be good for accessibility purposes (?).
    There are 2 tedious things with that system:
    1. the image dimensions must be computed in ems,
    2. the image dimensions depend on the text font size used on the page.
    If I change the page font size but want to keep my images as they were previously displayed, I need to go through these calculations again. It very quickly gets seriously annoying.
    I found one way of avoiding this: I define font-size:1px for each image. The great thing is that since I have body {font-size:100%}, it turns out that when the image has font-size:1px, then its dimensions are the same in pixels or ems. I mean that if I want to display my image with width:50px and height:10px, then I just need to specify width:50em and height:10em. Or at least the result is close enough not to be seen different to the naked eye. This only is useful if I am not modifying too much the page font size, e.g. font-size:0.95em to font-size:1.05em. So I thought this is great! But... there always are associated problems.
    Problems found so far:
    1. This only works if applied to the image, not its container (e.g. a floating div), so that the font-size doesn't propagate to any child element, e.g. a caption below the image.
    2. If the image is inside a div that is floated, then I need to set a width for that div and this width needs to be calculated with respect to the normal page font size, not my 1px—if this makes sense. If I were to change my image dimension, then I'd need to change this width too.
    3. It works fine with IE and Firefox, but no Safari and Opera.
    Hence the following questions:
    - Is this method totally absurd (as it probably sounds after my description) and/or infringing some basic rules?
    - Is there anything simpler?
    - Why doesn't it work in Safari or Opera?
    I'd be very grateful for any comment on this. Having started HTML and CSS only 1.5 month ago and not full time, I have no feeling at this stage whether this is a correct or acceptable way of thinking or not...
    Emilie

    - Is this method totally absurd
    Yes. Scaling images is very easy. Unless all your images are the same width, you will need to create an attribute selector for each image, but the principle is the same for each one.
    Let's say you have an image called mypic01.jpg, which is 600px wide.
    Remove the width and height attributes from the <img> tag. This displays the image at its normal size.
    Create the following style rule:
    img[src$="mypic01.jpg"] {
      width:50%;
      max-width:600px;
    This makes the image 50% of the size of its parent element, but ensures that it never grows bigger than its maximum size. Just use the image name in place of "mypic01.jpg", and adjust the correct value for max-width.
    The only drawback is that this won't be supported by IE6, which will simply display the image at its normal size. If it's important to support IE6, change from an atttribute selector to an ID selector like this:
    #mypic01 {
      width:50%;
      max-width:600px;
    Add the ID to the <img> tag:
    <img src="mypic01.jpg" alt="my scaling image" id="mypic01" />
    IE6 will ignore the maximum width, but will scale the image to 50% of the size of the parent element.

  • How to embed images dynamically?

    HI all , I'm new to flex.
    Here is what I've already done, I use
    [Bindable]   
    [Embed(source="images/xxx.jpg")]
    private var img:Class;
    to embed several images in an application.
    But the source of these images can not be determined until the run time, I got image's url dynamically, and used some variables to store them. For example, an url may refers to an url
    var url:String = "images/xxx.jpg";
    Then I think it's possible to give its value to an image source by using
    [Bindable]   
    [Embed(source=url)]
    private var img:Class;
    However,it doesn't work. there is a compile error, the description is:
    "url" does not have a recognized extension, and a mime type was not provided
    Unable to transcode url
    So what's the problem here, and could any one give me some advice to embed images dynamically?
    Thanks!

    HI
    I don't think you can embed an image dynamically as you need to know the path of the image when you use the embed tag.  The embedding takes place at compile time, and you app would need to be compiled into a swf before your code loads.
    If you need dynamc images in an application then its usually done by loading them when the app is running.  You do this by using for example a HTTP service to load in the image paths.  You can then view them by assigning them to an image tag through Actionscript.
    I hope that helps and I got the idea of what you were trying to do.
    Heres a quick example I used for someone else on swapping images from an arrayCollection.  You could do something like this and populate the arrayCollection using a HTTP service.  Or just access the xml from the HTTP directly for the image paths
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()" xmlns:local="*">
         <mx:Script>
              <![CDATA[
              import mx.controls.Button;
              import mx.collections.ArrayCollection;
    [Bindable]
    private var ac:ArrayCollection = new ArrayCollection([
    {imageTitle : 'Car 1', imageUrl : 'http://www.geekologie.com/2007/12/07/future-car-1.jpg'},
    {imageTitle : 'Car 2', imageUrl :'http://www.speedace.info/solar_cars/solar_car_images/Solar_Wing_front_Japanese_e lectric_powered_car.jpg'},
    {imageTitle : 'Car 3', imageUrl : 'http://www.dezeen.com/wp-content/uploads/2008/09/gem-peapod-car-by-chrysler-llc- et008_027evsqu.jpg'}
    private function showCar(num:int):void {
    img.source = ac.getItemAt(num).imageUrl;
    imgTitle.text = ac.getItemAt(num).imageTitle;
    ]]>
         </mx:Script>
         <mx:Image id="img" source="{ac.getItemAt(0).imageUrl}" width="426" height="243"/>
         <mx:Label id="imgTitle" text="{ac.getItemAt(0).imageTitle}"/>
         <mx:Button label="Button" click="showCar(0)"/>
         <mx:Button label="Button" click="showCar(1)"/>
         <mx:Button label="Button" click="showCar(2)"/>
    </mx:Application>
    Good luck
    Andrew

  • Rendering images dynamically from file server path

    Hi,
    We are having JDeveloper 11.1.2.4
    We have following requirement - Image files are located on server. File locations (path and name) are stored in database table.
    We need to dynamically access file locations from database table, access file from server and render it in ADF image component.
    Is it possible? If yes, we would really appreciate some pointers/help on how to achieve it.
    Please note that we are able to render images dynamically when they are stored in database BLOB column. We can do that using a ImageServlet class. In doGet() method, we are fetching the database BLOB column based on current row id.
    Thanks,
    Vivek

    Here is the scriplet I tried. But it is not redering the image and definitely I am missing something here. Please suggest changes or any direction.
    <%
    File f = image.getThumbnailFile(); //image file from a bean
    ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
    InputStream inputStream = new FileInputStream(f);
    byte[] bytes = new byte[1024];
    int read;
    try{
              while ( (read = inputStream.read(bytes)) > -1 )
                      byteOutput.write(bytes, 0, read);
              //byte[] ba = byteOutput.toByteArray();
              ByteArrayInputStream byteInput = new ByteArrayInputStream(byteOutput.toByteArray());
              response.setContentType("image/gif");                       
              while ( (read = byteInput.read()) > -1 )          
                   response.getOutputStream().write(read);
              response.getOutputStream().flush();
    catch(Exception e){}                           
    %>

  • Want to add Image Dynamically...

    I want to add image dynamically in my output screen..so is there any code that i can use..Please help with this...

    Can you please be more specific about what you want to do dynamically.  Do you just want to dynamically control which image appears in an image UI element (which can be done by data binding a context attribute to the image Source property) or do you want a dynamic number of images (which can be done with a row repeater or multipane UI element and inner Image UI elements).

Maybe you are looking for