Changing Image Control source

If I am changing the image in an Image component on the fly
by using either the "load" method or setting the "source" property,
is there anyway to accomplish this without seeing some flashing
while the new image is painted on the screen?
Thanks!

Hello Suresh,
Are you loading multiple images at once on one page? If so this is an expected behavior. There is limited memory available per app so it's important to not load too large or too many photos at once in your app.
If possible you can try to convert your Windows Phone 8 to Window Phone 8.1 so as to take advantage of the FlipView control which is built to handle photo gallery-like applications.
Also you can always run the Windows Phone Application Analysis tool to check on the application performance and memory usage. This will help you test and fine tune your app accordingly.
Let me know if this helps.
Abdulwahab Suleiman

Similar Messages

  • Image control source attribute

    I would like to protect my source files such as images from being downloaded or directly referenced by a URL by somebody other than my program. I thought may be an easy way to do that would be if I set the source to outside my webfolders. But my understanding is that in an Image control, the value of the property source has to be under my web root folder. Is there a way I can set the source to outside of my web folder and still have my flex app render the image od does some one have a different way of achieving the same objective. Thanks, Ramesh

    Hi there
    You can embed your image on the application.
    On FlexBuilder project, add a new source directory with your images... and in your source code some like this:
    <mx:Script>
    <![CDATA[
    [Embed(source="image/yourImage.png")]
    [Bindable]
    public var myImage : Class;
    ]]>
    </mx:Script>
    <mx:Image source="{myImage}"/>
    Regards

  • Setting Image control source to image in IsolatedStorage.

    Hi. I capture an Image and save it to IsolatedStorage. What's the URI (source for Image control) for IsolatedStorage to automatically display that image if it's available in IsolatedStorage? Thank you in advance.

    Try this code to retrieve the image from isoStore.
    It works for me.
    using (IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication())
    if (iso.FileExists(string.Format("image.png")))
    string fileName = "image.png";
    string filePath = iso.GetType().GetField("m_RootDir", System.Reflection.BindingFlags.NonPublic |
    System.Reflection.BindingFlags.Instance).GetValue(iso).ToString() + fileName;
    You can set the source of the Image to filePath and you won't have any problem accessing it.
    If this doesnt work, then the problem is while you are saving the image. You might have to find a workaround for saving the canvas to png or jpeg.
    If my reply answers your question, please mark this post as answered.

  • Image control

    I have a table including image content as xstring type and image type.
    I wanna display the image content on a wd image control.
    Is it possible?
    I knew the image control displays a certain image as url source.
    How can I display the image content in a table on WD view?
    Regards Jun

    I solved this problem thanks to your help using cache.
    I sent the image content to cache area and then created a temporary cache url.
    The url is bound to image control' source.
    Everything is OK now. Thank you for your Idea.

  • Image control with a movieclip source

    I have an image control sitting inside a panel. The images
    source is a movieclip. When I change the change the size of the
    movie clip (scale X, scale Y) the movie clip exceeds the boundary
    of the image and the panel, so no scroll bars are shown. Can anyone
    shed some light on this? I'm stumped.

    Hey Guys,
    A couple things:
    We don't have preloader scripts, but the way I do it is to
    load them from a regular data set and put them into a hidden DIV. I
    use that here:
    http://www.dbooth.net/photos/index.htm?location=italy2007#
    The thumbnails are loaded into a DIV that is hidden. They are
    then available as previews when you mouseover the numbers.There is
    a lag of course, since that do have to load at some time.
    As for MySQL scripts, we have a util file here:
    http://labs.adobe.com/technologies/spry/samples/utils/query2xml.html
    We have two versions for each language: One that will just
    auto-convert a query and another that allows you to create your own
    node names.
    Let me know if you have questions.
    Don

  • Change image source distorts new image

    Is there any easy way, once I change image source in Edge Animate, to get it to at least be proportionally correct? When I change an image source with a different size, it comes in distorted.

    If you change the source it will fill the boundaries of the original source image automatically. If the size is different, it is probably better to delete the original image and drop the new one.
    If you are talking about loading an image dynamically and changing them dynamically, use css background image with no-repeat and have you div be the size of the largest image used unless you code the image size when they change.

  • Change images dynamically in Repeater

    Hi,
              I have an image control inside repeater.  I need to change the images dynmically during mouseover and mouseout.
    Regards,
    Jayagopal.

    HI Jayagopal,
    Just replace these below two functions in your code...
    You are accessing the rxImage.currentItem which is not available after the Repeater has completed looping through the items. However if you want to get the details of the item clicked you can make use of the getRepeaterItem() function in conjunction with the current target.
    var currRepItem:Object = event.currentTaget.getRepeaterItem();
    private function onMouseOver(event:MouseEvent):void
                    var localIndex:int=arsImage.length-1;
                    var currItem:int = event.currentTarget.getRepeaterIndex();
                    //imgSource[rxImage.currentItem].source = arsImage[mouseOverindex+1].label;
                    var imgSource:Image = event.currentTarget as Image;
                    imgSource.source = arsImage[mouseOverindex+1].label;
                    mouseOverindex += 1;
                    if(localIndex == mouseOverindex)
                        mouseOverindex=0;
                private function  onMouseOut(event:MouseEvent):void
                 var imgSource:Image = event.currentTarget as Image;
                    imgSource.source=arsImage[0].label;
    Thanks,
    Bhasker

  • Crystal ActiveX Runtime Lib: Change text data source path at run time.

    We have some PCs running Crystal Reports 10 and some running CR 9 and 8.5. For each PC, we set up a System DSN ODBC data source (in Control Panel - Administrative Tools) for pulling data from text files to
    generate reports.
    Recently we wrote some routines (see the Visual Basic example at the
    end of this message) to change the path of the data files at runtime.
    According to the Crystal Reports Technical Reference Guide, we may use
    the method LogOnServer() of an Application object or an DatabaseTable
    object. However, we find that this does not work: the PrintOut()
    method only pulls data from the default path as configured for the
    System DSN, not from the path passed as the third parameter of
    LogOnServer(). It does not return any error message.
    We have also tried to use SetTableLocation() method, and it still does
    not work.
    Would any experts examine our code below and advise what we are missing? Thanks.
    For the following VB example, we have:
    System DSN Name: AP_WORKSHEET
    Driver: Microsoft Text Driver
    Database Directory: D:\0ood2 (i.e. the default path)
    Crystal Report Document: D:\3g\run\Vision\apcyto\Reports\crBlockWS.rpt
    (Which specifies that the data source text file name is BlockWS.txt)
    Purpose : We would like to read the data source text file from
    D:\0ood1 instead of the default path.
    Following is the code of the VB macro:
    Sub test()
    Rem In this version of the subroutine, we call
    Rem DatabaseTable.LogOnServer() and "Rem"ed out
    Rem Application.LogOnServer() and SetTableLocation().
    Rem We have un"Rem"ed each of them and "Rem"ed others and try to run.
    Rem In all runs, data are pulled from the default file
    Rem D:\0ood2\BlockWS.txt instead of D:\0ood1\BlockWE.txt.
    Dim crxapp As CRAXDRT.Application
    Dim crxRep As CRAXDRT.Report
    Dim crxDB As CRAXDRT.Database
    Dim crxTab As CRAXDRT.DatabaseTable
    Dim crxConnPs As CRAXDRT.ConnectionProperties
    Dim crxConnP As CRAXDRT.ConnectionProperty
    Dim apropSubLoc As String
    Dim apropConnBufStr As String
    Set crxapp = CreateObject("CrystalRuntime.Application")
    Rem
    crxapp.LogOnServer "p2sodbc.dll", "AP_WORKSHEET", "<CRWDC>DBQ=D:\0ood1",
    Set crxRep = crxapp.OpenReport
    ("D:\3g\run\Vision\apcyto\Reports\crBlockWS.rpt")
    Set crxDB = crxRep.Database
    Set crxTab = crxRep.Database.Tables(1)
    apropConnBufStr = crxTab.ConnectBufferString
    apropSubLoc = crxTab.SubLocation
    crxDB.LogOnServer "p2sodbc.dll", "AP_WORKSHEET", "<CRWDC>DBQ=D:\0ood1",
    Rem crxTab.SetTableLocation "D:\0ood1\BlockWS.txt", apropSubLoc, "DSN="
    Rem Set crxConnPs = crxTab.ConnectionProperties
    Rem Set crxConnP = crxConnPs.Item("DSN")
    Rem crxConnP.Value = "AP_WORKSHEET"
    Rem Set crxConnP = crxConnPs.Item("Database")
    Rem crxConnP.Value = "D:\0ood1\BlockWS.txt"
    Rem crxTab.Location = "BlockWS.txt"
    crxRep.DiscardSavedData
    crxRep.PrinterSetup (0)
    crxRep.PrintOut
    End Sub
    For VB macros, the problem exists in all of CR 8.5, 9 and 10. However,
    for another platform we are using, Unify Vision 4GL, it works for CR
    8.5 while not working for CR 9 and 10.
    Following is the source code in Unify Vision 4GL. This language may
    not be popular, but I thin you are about to see how it calls the
    Runtime Library methods LogOnServer(), OpenReport(), PrinterSetup() and
    PrintOut().
    %gfPrintCrystalReport
    BOOL FUNCTION gfPrintCrystalReport($reportName)
    BEGIN
    if NOTMKNOWN(GF:$oSeagateId) then
    create service of activex
    class 'CrystalRuntime.Application'
    object_ref into GF:$oSeagateId;
    if MKNOWN(GF:$oSeagateId) then
    begin
    /* TD23013: Database directories are dynamic to
    accommodate multiple user requirement of Citrix */
    send message LogOnServer to GF:$oSeagateId
    using
    ( 'PDSODBC.DLL', 'AP_WORKSHEET', '<CRWDC>DBQ='+GF:$WinTempDir,'','')
    identified by $msgHandle;
    if $msgHandle:MSG_STATE 'RESPONSE_PROCESSED'
    then
    begin
    display 'Crystal Reports cannot connect
    to the datasource ' for fyi_message wait;
    return (FALSE)
    end
    send message OpenReport to GF:$oSeagateId using
    ($reportName, 1)
    identified by $msgHandle returning
    $oCrystalReport
    if MKNOWN($oCrystalReport) then
    begin
    if (NOTMKNOWN(GF:$printerName)) then
    set GF:$printerName to
    $oCrystalReport->PrinterName;
    if GF:$printerName $oCrystalReport-
    PrinterName then
    send message SelectPrinter to
    $oCrystalReport
    using
    (GF:$driverName,GF:$printerName,GF:$portName)
    identified by $msgHandle;
    set $oCrystalReport-
    DisplayProgressDialog to FALSE;
    while TRUE
    begin
    DISPLAY NOTICE 'Print to : ' +
    GF:$printerName
    LABELS 'Ok'
    DEFAULT, 'Cancel', 'Printer Setup'
    RESULT INTO $userOption
    switch ($userOption)
    begin
    case 0 :
    send
    message PrintOut to $oCrystalReport
    using
    (PROMPT_USER, NUMBER_OF_COPIES, COLLATED, START_PAGE, STOP_PAGE)
    identified by $msgHandle;
    set
    $oCrystalReport to UNDEFINED
    return
    (TRUE);
    case 1:
    set
    $oCrystalReport to UNDEFINED
    return
    (FALSE);
    case 2:
    send
    message PrinterSetup to $oCrystalReport
    using
    (0)
    identified by $msgHandle;
    if
    GF:$printerName $oCrystalReport->PrinterName then
    begin
    set GF:$printerName to $oCrystalReport->PrinterName;
    set GF:$driverName to $oCrystalReport->DriverName;
    set GF:$portName to $oCrystalReport->PortName;
    end
    break;
    end
    end
    end
    end
    return
    (FALSE);
    END

    Hi Sydney,
    If you search the Developers help file you'll find info on using the method:
    How to change the data source
    This example demonstrates how to change the data source from native Access to an OLEDB (ADO) data source by using the ConnectionProperty Object, as well as how to change the table name by using the Location property of the DatabaseTable Object. CrystalReport1 is connected to the xtreme.mdb database found in the \Program Files\Crystal Decisions\Crystal Reports 10\Samples\En\Databases folder. The report is using the Customer table. A copy of the Customer table is added to the pubs database on Microsoft SQL Server.
    ' Create a new instance of the report.
    Dim Report As New CrystalReport1
    Private Sub Form_Load()
    ' Declare a ConnectionProperties collection.
    Dim CPProperties As CRAXDRT.ConnectionProperties
    ' Declare a DatabaseTable object.
    Dim DBTable As CRAXDRT.DatabaseTable
    ' Get the first table in the report.
    Set DBTable = Report.Database.Tables(1)
    ' Get the collection of connection properties.
    Set CPProperties = DBTable.ConnectionProperties
    ' Change the database DLL used by the report from
    ' native Access (crdb_dao.dll) to ADO/OLEDB (crdb_ado.dll).
    DBTable.DllName = "crdb_ado.dll"
    '  The connection property bags contain the name and value
    ' pairs for the native Access DLL (crdb_dao.dll). So we need
    ' to clear them, and then add the name and value pairs that
    ' are required to connect to the OLEDB data source.
    ' Clear all the ConnectioProperty objects from the collection.
    CPProperties.DeleteAll
    ' Add the name value pair for the provider.
    CPProperties.Add "Provider", "SQLOLEDB"
    ' Add the name value pair for the data source (server).
    CPProperties.Add "Data Source", "ServerA"
    ' Add the name value pair for the database.
    CPProperties.Add "Initial Catalog", "pubs"
    ' Add the name value pair for the user name.
    CPProperties.Add "User ID", "UserName"
    ' Add the name value pair for the password.
    CPProperties.Add "Password", "password"
    ' Set the table name. ' for SQL types it would be "database.dbo.table"
    DBTable.Location = "Customer"
    Screen.MousePointer = vbHourglass
    ' Set the report source of the viewer and view the report.
    CRViewer1.ReportSource = Report
    CRViewer1.ViewReport
    Screen.MousePointer = vbDefault
    End Sub

  • Open a disk image file and crop it to an Image control

    Hi Folks,
    I am trying to allow my users (in a browser) to select/open a disk file (image type) so that they can see it and then save it to the server.  I can use the FileReference object just fine, and load its 'result' directly into a MX:Image control.  However, before I do that I would like to crop the selected imaged to a square shape.  I'd also like to resize the image down, but that will come later, once I get the cropping working.
    I am essentially taking the FileReference result bytearray and converting that to a BitmapData object.  Then, I 'extract' a square of data from that BitmapData object into a new BitmapData object.  Then I need to get *that* BitmapData object into the mx:image control.  I tried using a Bitmap to do so, however the resulting mx:image, while 'sized' correctly, displays as a blank white region.  All along, the variables seem to be 'full' of data and seem to have properly set attributes.  I've looked up quite a few sites that demonstrate cropping, and copying images, but they always start out with 'pre-loaded' images.  I have modeled my code after theirs, where appropriate.
    Here is my code:
              //this gets called when the user clicks a button to 'look for a disk file'
                private function setPhoto():void
                    //create the FileReference instance
                    _fileRef = new FileReference();
                    _fileRef.addEventListener(Event.SELECT, onFileSelected);
                    //listen for the file has been opened
                    _fileRef.addEventListener(Event.COMPLETE, onFileLoaded);
                    var arr:Array = [];
                    arr.push(new FileFilter("Images", ".gif;*.jpeg;*.jpg;*.png"));
                    _fileRef.browse(arr); //then let go and let the event handlers deal with the result...
                private function onFileSelected(evt:Event):void
                    _fileRef.load(); //the result of the 'load' will be handled by the 'complete' handler
                private function onFileLoaded(evt:Event):void
                    var tempLoader:Loader = new Loader();
                    tempLoader.loadBytes(_fileRef.data);
                    tempLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
                    //imgPhoto.source = _fileRef.data;  //this would work just fine, though, it wouldn't be cropped
                private function onLoaderComplete(event:Event):void
                    var loaderInfo:LoaderInfo = LoaderInfo(event.target);
                    var loadBD:BitmapData = new BitmapData(loaderInfo.width,loaderInfo.height);
                    //ok, now that we have the 'original' file in the bitmap data, we can crop it and then later resize it
                    //so, we need a 'square' of image cropped out of the original
                    //so...first we get a square of the 'full size' image
                    //if the image is taller than wide, we will take a square as wide as the image, and as tall as it is wide, starting 5% down from the top
                    //if the image is wider than tall, we will take a square as tall as the image, and as wide as it is tall, from the horizontal middle
                    var curW:int = loadBD.width;
                    var curH:int = loadBD.height;
                    var cropX:int = 0;
                    var cropY:int = 0;
                    var cropW:int = curW;
                    var cropH:int = curH;
                    var needCrop:Boolean = true; //default is to crop
                    var croppedBD:BitmapData;
                    if (curH > curW)
                        cropY = Math.round(curH * .05); //start at 5% down
                        cropH = cropW;
                    else if (curW > curH)
                        cropX = Math.round(curW/2) - Math.round(curH/2); //start at the middle, go 'back' by half the height
                        cropW = cropH;
                    else
                        needCrop = false; //it's already a square!  nothing to do (aside from the resize)
                    if (needCrop)
                        croppedBD = new BitmapData(cropW, cropH); //at this point it is 'empty', so fill it up
                        var fillPoint:Point = new Point(0,0); //since we're gonna fill into the top, left pixel on down and over
                        var fillRect:Rectangle = new Rectangle(cropX,cropY,cropW,cropH);
                        croppedBD.copyPixels(loadBD,fillRect,fillPoint);
                    else
                        croppedBD = loadBD;
                    imgPhoto.source = new Bitmap(croppedBD);  //this produces a properly sized, but blank-white image
    And here is the mxml for the image:
    <mx:Image id="imgPhoto" x="40" y="126" maxWidth="200" maxHeight="200" />
    Thanks!
    -David

    Hi,
    You were close to the solution.
    In "onLoaderComplete(event:Event):void", at the begining you create a BitmapData called "loadBD", you just forgot to fill it with the content from the loaderInfo.
    private function onLoaderComplete(event:Event):void {
         var loaderInfo:LoaderInfo = LoaderInfo(event.target);
         var loadBD:BitmapData = new BitmapData(loaderInfo.width,loaderInfo.height);
         loadBD.draw(loaderInfo.content);
    Kind regards,
    Mich

  • How to add an image to an IMAGE control in Java WebDynpro

    hi
    How to add an image to an IMAGE control in Java WebDynpro.
    Please give me the steps to assign an image to an IMAGE control.
    Advanced Thanks
    brahma

    Thank You Mathan MP,
    i tried these steps, but whenever i selected the source property of image UI control, it opens a context window, but this context window does't contain any thing for selection.
    so how to solve this problem ?
    the link whatever u provided is not opened, please send the correct link.
    http://127.0.0.1:1284/help/index.jsp?topic=/com.sap.devmanual.doc.user/f3/1a61a9dc7f2e4199458e964e76b4ba/content.htm
    Thanks in Advance
    brahma

  • ALE Change Pointers in source system not active

    Hi All,
    I am trying to load 0COSTELMNT using deltas. The initial load is OK and then i use a delta and it fails and i get the error:
    "ALE Change Pointers in source system not active"
    I have carried out the following steps in an attempt to resolve the problem - but it didnt. Anyone have any advice??
    (1) Checked BD61 – to confirm whether the change pointers are active
    (2) Checked BDCP to confirm the number range is maintained
    (3) Checked SALE (Activate change pointers for message types)  to confirm whether the change pointer has been activated for the type we need:
    COCOKA     Control segment CO object/cost element
    COELEM     Cost element master data
    (4) In transaction snum, Selected number ranges and confirmed the intervals are setup
    No. 01
    FROM: 0000000001
    TO: 0000009999
    (5) Activate transfer structure
    (6) Replicate Datasources
    Thanks,

    If you are transferring master data from source system, the BD61 setting on the source system should be checked.
    Why it has been unchecked - not sure (likely someone did it by mistake).
    It shouldn't have any effect on txnl delta. What will be effected though is that you will have lost delta of the ALE based data sources for the period this setting was unchecked.

  • Image control runtime creation issue

    I am having problems getting the Image control to actually
    display the image I specify in the source property. The Image
    control is created in actionscript at runtime based on XML returned
    by an HTTPService request. I have a canvas that I want to populate
    with Label, Text, Image, LinkButton, etc. controls based on the
    contents of the XML file that is read in, so I have to create all
    the components on the fly and use something like this:
    var newImage:Image = new Image();
    newImage.setStyle("source", "images/myImageFile.jpg");
    myCanvas.addChild(newImage);
    After I get all the newly created components added as
    children to the canvas I go back through and do positioning
    (something like this):
    for each (var child:DisplayObject in myCanvas.getChildren())
    //set the y property of each component to the y of the
    previous child plus
    //the height of the previous child plus 10 px margin
    Wherever there is an image in my XML it inserts the 10px
    margin for that component, so I know it's creating it and that it
    gets added as a child, but for some reason the image is not
    displaying and so the height of the component is 0. I even tried
    hardcoding the height of each Image control in case the image was
    there but it just wasn't sizing right, but it puts in the space
    without displaying the image.
    What I'm wondering is if there is some method that will force
    the Image controls to either load the image or render it. When I
    add an Image in mxml and use the exact same source data it displays
    just fine, so the file path is correct. I also have the same images
    being read in from XML off the HTTPService that are showing up just
    fine in a TileList where my itemRenderer component has an image
    with the source set to the same path as I'm trying to use in the
    runtime-generated Image controls.
    Also, as a side question, does anyone know why a lot of the
    properties/methods available from mxml specified comonents aren't
    available when you create variables of the same type in
    actionscript? For example, if I have
    <mx:Image id"img"/>
    I can go back in actionscript and reference img.source just
    fine. On the other hand, if I declare an Image in actionscript,
    thus:
    private var asImg:Image = new Image();
    and then try to refer to the source property like so:
    asImg.source
    it doesn't show up in the code hinting and it also throws an
    error on compile (reference to a possibly undefined property source
    for bla bla bla)
    Actually, I've noticed that a lot of the properties and
    methods of various components aren't available when they are
    actionscript rather than mxml. I didn't see much in the
    documentation on the difference or what could be done to work
    around it.
    Thanks much anyone who has input.

    Ok, got it.
    I figured that since the <mx:Image> renders just fine
    and that the ActionScript Image object doesn't that I'd just create
    a custom mxml component with Image as the base element and with
    nothing else in it. Then I add an instance of my custom image
    component in AS whenever the XML specifies one. The layout was a
    bit of an issue, but I just added the image dimensions as
    attributes in my XML and size the CustomImage component based on
    those.
    Must be some subtle difference between the mxml and AS Image
    classes that isn't documented very well.

  • Image control- setting images conditionally

    Hello All!
    I am a Labview newbe and I need help with image control. I have a set of two images- one static png and one animated gif.  I want to use these two images as an activity indicator in a picture box or other control.  I can send one or the other to the picture box programmatically in the function block screen but I do not understand how to set the image control conditionally for condition "A" and condition "B". The code below is for two separate picture boxes.  My goal is to select one image to show in a single box depending on conditions "A" or "B". The two conditions are "not running" and "running". Can this be accomplished with boolean logic?   I also hope to use such a control in the future for multiple conditions to help illustrate to the user a specific hardware item to pay attention to. I am using LV 2014 on a Windows 7 box. The built VI will be used on Windows 7 and XP. 
    -cmengineer

    Happy Sunday Evening All!
    I have included all files in the zip file.  I changed the image for one state to a jpeg and changed the control to a jpeg control.  This works to demonstrate the state change but my goal is to use the gif which is shown as decoration in the middle of the vi front panel as the running state indicator.
    Now that I have tested it, I think I need to work on the file write operation as well.  Instead of getting my four points of data in a row, I get one or another.  Always fun!
    -cmengineer
    Attachments:
    MyPTA_Monitor2.zip ‏1554 KB

  • Change images on mouse click

    hi,
    cud anyone help me to change image in a JPanel in JFrame.On MouseClick event. the image should in an panel on mouseclick,plz explain with example source code.
    thank u

    I dvlp MyPanel to accept 2 image file name.
    You can easy change to accept Image instead of file name.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class Test {
    public static void main(String args[]) {
    JFrame f = new JFrame("Test");
    MyPanel p = new MyPanel("YourFirstImage.gif", "YourSecondImage.gif");
    p.add(new JButton("Click on Panel (not Button)"));
    f.setContentPane(p);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
    class MyPanel extends JPanel implements MouseListener {
    Image image, image1, image2;
    public MyPanel(String image1Name, String image2Name) {
    //load image
    try {
    image1 = getToolkit().getImage(getClass().getResource(image1Name));
    image2 = getToolkit().getImage(getClass().getResource(image2Name));
    MediaTracker mt = new MediaTracker(this);
    mt.addImage(image1, 0);
    mt.addImage(image2, 0);
    mt.waitForAll();
    } catch (Exception e) { e.printStackTrace(); }
    this.image1 = image1;
    this.image2 = image2;
    this.image = image1;
    this.addMouseListener(this);
    public void paintComponent(Graphics g) {
    g.drawImage(image, 0, 0, this.getWidth(), this.getHeight(), this);
    public void mouseClicked(MouseEvent e){
    image = (image == image1) ? image2 : image1; // switch between image1, image2
    repaint();
    public Dimension getPreferredSize() {
    Dimension dim = super.getPreferredSize();
    int w = Math.max(image1.getWidth(this), image2.getWidth(this));
    int h = Math.max(image1.getHeight(this), image2.getHeight(this));
    w = Math.max(dim.width, w);
    h = Math.max(dim.height, h);
    return new Dimension(w, h);
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}
    public void mousePressed(MouseEvent e) {}
    public void mouseReleased(MouseEvent e) {}

  • How to fit image in image control?

    I am using image control to display images.
    I have placed image control inside canvas.
    While loading I am maintaining image aspect ratio and based on it i am resizing image and canvas both.
    Now i have requirement that I dont want to change height and width of image and canvas control, instead image should be scalled to fit in canvas.
    I know image have scaleX, scaleY and scalecontent property.
    Can anybody guide me how to calculate scaleX and scaley so image fits in image control?
    Thanks,
    -CK

    did you try scaleContent="true"

Maybe you are looking for

  • Command S not working in Dreamweaver CS6

    Command S not working in Dreamweaver CS6

  • Book proofer still not working

    Book Proofer is still not working under iOS 8.0.2. This has slowed our ePub production to a crawl. Apple can you please update this little utility.

  • PC HANG every time I ligin Windows XP

     Hi, I'm Jerry from Malaysia.I'm facing the problem is my PC will HANG every time I try to login windows ..I already test my vga with the Hardware Diagnostics utility..It say that my card has no problem. My VGA card Technical Support ask me to Update

  • Cannot connect with someone using AIM on a PC

    it keeps saying she's declining my invitation. Anyone? when she tries to connect to me and I select connect, it pops up with "there was a communication error during the chat"

  • Request for iPhone 5 with words of wisdom

    Respected sir, I recently saw your offer words of wisdom and im really looking forward to it. Can you please give me an option on iPhone 5 as I would like to give iPhone 5 to my lovely dad on the fathers day kindly let me as soon as possible. Thank y