Draw 20% of one image and 80% of another?

Hi all,
I'm creating a UI functionality whereby a user holds down a button and an image of a glass slowly fills up.
The way I'm thinking of implementing this is to have two different images, one of the empty glass and one of the full glass. As the user holds down the button, the image of the first is slowly replaced by the image of the second. E.g., after one second, 20% of the full image is shown at the bottom, 80% of the first is shown at the top.
The timing stuff I think I can do with a thread, so I'm not too worried about that. However, what I need is a simple method, or maybe a whole class, that can take two images and draw x% of one on the bottom and y% of the other on the top.
Can anyone think of a simple way to implement this?
Thanks,
Tim

Hmmm... after playing with that a while, it doesn't look like that will do the trick. As far as I can tell, the drawImage methods will always scale the image if you pass it in a rectangle of a different size. So trying to get 50% of a full glass on top of an empty glass results in a squished full glass.
Instead I realized I could do it using Graphs.clipRect, like so:
public class OverlayedImageIcon extends ImageIcon
     private Image overlayImage;
     private float overlayPercent;
     public OverlayedImageIcon(URL url)
         super(url);
     public void setOverlayImage(Image image){
          this.overlayImage = image;
          loadImage(overlayImage);
     public void setOverlayPercent(float percent){
          this.overlayPercent = percent;
     public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
          super.paintIcon(c, g, x, y);
          Shape oldClip = g.getClip();
          int subtractHeight = (int) ((float)getIconHeight() * overlayPercent);
          g.clipRect(0, getIconHeight() - subtractHeight, getIconWidth(), getIconHeight());
        g.drawImage(overlayImage, x, y, getIconWidth(), getIconHeight(), getImageObserver());
        g.setClip(oldClip);
}Thanks for pointing me in the right direction, though!

Similar Messages

  • How can I take an item from one image and move it to another image?

    How can I take an item from one image and add it to another image, and rotate it to fit?

    Carefully select the objects of interest in one image and then copy, scale and position them into the other image. Then touch up the composite.
    Have to Love Photoshop for Retouching Images!

  • Is it possible to clone an object from one image and paste it on another image?

    Is it possible to clone an object from one image and paste it on another image in Aperture?

    As Frank said,
    but Aperture has a nice clone tool - the drawback is, that it only works within one image.
    What I sometimes do - as a workaroud, when I want to use the clone brush, is to combine the image I want to clone from and the image I want to clone into, into one single image by printing them together to pdf as jpeg. Then I can clone from the second to the first, for example, to be able to add an fairy to a flower: Picking up the head of the fairy in the right image and brushing it into the left one. Occasionally I prefer the Aperture brush to the Photoshop lasso.

  • Can Aperture lay one image on top of another?

    Remember the days of sandwiching two negatives and printing them as one image?
    OK, most of you who can answer me were not born then. But that's what I want to do with two files—can Aperture do this for me?
    Thanks,
    Ben

    Unfortunately, no.
    You will need a program that can composite (typically with layers and transparency capabilities) so one image can show through another to varying degrees.
    The most expensive option is Photoshop full version ($700) and the least would be Gimp (which is free).
    Note - there are many other programs between the above price range including Photoshop Elements which will easily do the trick and more.
    Editing this one to add that Pixelmator looks like a promising app and is available as a trial at their site:
    http://www.pixelmator.com/
    They also have a sneak peak of Pixelmator 2 which a new purchaser can purchase the current version from the Mac App Store for $29 and will receive Pixelmator 2 as a free upgrade when released.
    http://www.pixelmator.com/sneak-preview/
    I would suggest giving this one a try before looking at Photoshop or Gimp.

  • Click on link in one portlet and open in another portlet

    how do you click on link in one portlet and open in another portlet?

    Hrmm... This is a IBM Question..
    Officially this is a meaningless buzzword promoted by IBM. Portals are some sort of Servlet but IBM incapable of explaining how they differ from ordinary Servlets. Some speculate they are used to present a webpage with many services on it such as a search engine, and news that come from diverse sources. The user is able to dynamically configure the contents and layout of the page much like Netscape home pages
    I don't understand what yhour asking..
    I am assuming you want to call another servlet (portlet)? That would be absurd to do .. You let the HTTP request and XML file to deal with the response of the portlet

  • How do you take pictures from one library and put in another library??

    How do you take pictures from one library and put in another library??

    Options:
    1. Export from iPhoto A to the Finder, then import to iPhoto B
    This gets the photo over, but no versions, no edit history and not all the metadata
    2. Use iPhoto Library Manager
    This gets everything: versions, edit history and all the metadata.
    Regards
    TD

  • How to set cookie value in one page and retrieve in another page using setA

    How to set cookie value in one page and retrieve in another page using setActionListener?
    I have tried with following code srcpage.jspx->destpage.jspx
    srcpage.jspx
    <af:table value="#{bindings.DepartmentsView1.collectionModel}"
    var="emp" rows="#{bindings.EMPView1.rangeSize}"
    first="#{bindings.EMPView1.rangeStart}"
    emptyText="#{bindings.DepartmentsView1.viewable ? 'No rows yet.' : 'Access Denied.'}">
    <af:column sortProperty="EmployeeName" sortable="false"
    headerText="Cookie Testing">
    <af:commandLink text="#{emp.EmployeeName}" action="success">
    <af:setActionListener from="#{emp.EmployeeName}"
    to="#{cookie}"/>
    </af:commandLink>
    </af:column>
    </af:table>
    espage.jspx
    <af:outputText value="Test Cookie Value: #{cookie}"/>
    ,Here Test Cookie Value prints the following instead of its original String value
    {JSESSIONID=javax.servlet.http.Cookie@7da288, oracle.uix=javax.servlet.http.Cookie@399f62}
    I have passed employee name "Robert" to cookie in srcpage.jspx,but it prints "JSESSIONID....." instead of "Robert" in destpage.jspx
    Thanks in advance
    Kalee

    Hi,
    "cookie" is a reserved name. If you want to write to a session scope attribute called "cookie" then you have to call #{sessionScope.cookie}. If you want to use EL to set and read from cookies then you will have to use
    #{cookie.cookieName}
    Note that #{cookie} writes to and returns a map
    check this: http://www.informit.com/articles/article.aspx?p=30946&seqNum=7
    Frank

  • I run Tiger OSX on one MacBook and SnowLeopard on another. Photos were downloaded from Tiger to SnowLeopard, and now iPhoto won't open on the Tiger Mac. Will upgrading iPhoto fix this problem?

    I run Tiger OSX on one MacBook and SnowLeopard on another. Photos were downloaded from Tiger to SnowLeopard, and now iPhoto won't open on the Tiger Mac. Will upgrading iPhoto fix this problem?

    What matters is the version of iPhoto you have on the different machines. Can you tell us what they are, and what exact error message you get.
    Regards
    TD

  • HT3819 i have all my itunes on one computer and have brought another and need to transfure all my exsisting music to this new computer, how do i do this? please help.

    I have all my itunes on one computer and have brought another and need to transfer all my music etc to new one, how do i do this? please help its doing my head in!

    Hey allen72,
    Thanks for the question. I understand you wish to transfer your iTunes library to a new computer. There are a few different options for doing so, the following article provides more information:
    iTunes: How to move your music to a new computer
    http://support.apple.com/kb/HT4527
    Thanks,
    Matt M.

  • How display top 3 revenues in one block and remaining in another block

    How display top 3 revenues in one block and remaining in another block.

    create a variable as
    v_Rank =Rank([Revenue])
    then create a block level filter on the 2nd block as v_Rank Greater than 3.
    you may need to modify the variable formula as per requirement to get the rank of the row.

  • Rollover on one image and another jumps up!

    Please respond to my email: [email protected]
    How do I solve this problem-- In my image gallery, I mouse
    over on an image and up comes the image, HOWEVER, another image
    jumps up too.... Since all five images are in a row with space
    between each. When I mouse over, one or two more images sometimes
    jump up when they are not supposed to. HOW DO I SOLVE THIS????
    HELP.
    There are eight frames on timeline for the tweening. I click
    on SCENE, and choose ACTIONS: the Actionscript I put in separately
    for each movie clip is shown below:
    on (rollOver) {
    this.gotoAndPlay(2);
    this.swapDepths(1);
    on (rollOut) {
    this.gotoAndPlay(8);

    This worked for me:
    1) Figure out what the broken genre is, and where it goes.  For example, I would touch "Rock" and get a list of "Pop".
    2) Remove from the device all songs from the targeted genre ("Pop" in my example), while keeping songs that belong to the broken genre ("Rock" in my example).  I sync everything, so for me this meant changing to "Selected playlists, ..." and then checking all the genres except the one I didn't want.  (Renaming the targeted genre will not work.  The songs need to be removed.  I found that there seemed to be one song that triggered the bad link.)
    3) Use the device to access the broken genre again ("Rock" in my example).  It will re-index (this took a few seconds for me) and then display the correct entries for the genre.
    4) Repeat steps 1-3 for any other broken genres.
    Certainly this is a bug, but these steps allowed me to work around it.

  • How can you use one image and edit it three different ways to export later?

    I am a new Lightroom 3 user.  How can use the same image and edit it multiple ways to produce mulitple images to later export?  For example,  I have a picture of a bride and groom.  I want to use that image and create a color image, a black and white image, and a close up of their hands.

    Do I need to do either of those options before I start editing the image at all?  For example,  what if I am working on the image and doing some creative edits.  Then I think of another option that I could do.  Is it too late at that time or can I still get the original image to begin with?

  • Can I attach a link to one image and then use that linked image multiple times in my site?

    Hi,
    Is it possible to attach a link to an image and then use that image (with link attached) multiple times in my site.
    Thanks,
    Ally

    Use 'Find and Replace'>under the 'Edit' menu.
    Select from 'Find in'- Folder and browse to the folder your website files are kept in to select it.
    Search: Source Code
    In the Find box (but obviously use YOUR image code):
    <img src="images/imageName.jpg" width="200" height="200" alt="" />
    In the Replace box: (use YOUR link and image code)
    <a href="yourLink.html"><img src="images/imageName.jpg" width="200" height="200" alt="" /></a>
    Then select 'Replace All'

  • How to cut out part of an image and replace with another?

    ok, i'm a newbie to image editing, and i want to cut out a persons face in a picture and put in another face on the picture. i'm sure this is pretty simple, i just have no idea where to start. can someone point me in the right direction? thanks!

    Aperture is not a pixel editor, which is what you need. Photoshop is the app used for this, but it's cost is several times that of AP! As suggested in the second post, look into Photoshop Elements, a slimmed-down and much cheaper version of Photoshop. [I don't use Elements, so if someone knows that it can't do area copies from one pic to another, please join the conversation!]
    And get a good book on Photoshop or Elements, there's a huge learning curve involved. I'd suggest going to a book shop, pulling a few such books off the shelf and check their index for editing techniques. Sometimes you'll find one book that gives you the exact step-by-step instructions for doing what you want. Then there'll be others that don't get into the topic or do a poor job.

  • How to get the data from one table and insert into another table

    Hi,
    We have requirement to build OA page with the data needs to be populated from one table and on save data into another table.
    For the above requirement what the best way to implement in OAF.
    I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
    Thanks

    You can achieve this in many different ways, one is
    1. Create another VO based on the EO which is based on the dest table.
    2. At save, copy the contents of the source VO into the dest VO (see copy routine in dev guide).
    3. commiting the transaction will push the data into the dest table on which the dest VO is based.
    I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
    if by table you mean a DB table, then no, you can have a VO based on multiple EOs which will do DMLs accordingly.Thanks
    Tapash

Maybe you are looking for

  • Maximum File size in XI

    I have 100 MB file to be transferred through XI. How to check maximum file size limit in XI server. Is thier any tcode for the same?

  • A point to clear from note 823587.1

    Current Environment: ============= 2 Nodes ("Node-1" and "Node-2") for database tier. 2 Nodes ("Node-3" and "Node-4") for application tier. EBS Version: 12.1.3 Database Version (On "Node-1"): 11.2.0.3 We installed db on "Node-1" and apps on "Node-3"

  • Exposure change after Photoshop freeze and MBP restart

    Strange thing and I need help. Last night I was editing pictures with PSCS and viewing in iphoto when PS quit opening (I click on the icon but the program would not open, just bounce in the dock for a second). I restarted my MBP and all of my photos

  • Multisim won't allow me to open 2 separate designs simultaneously. How can I fix this?

    I downloaded the Mutlisim 13.0 Trial version first. When the trial period was over I purchased a student license and activated it. Now when I try to open a new design when an existing one is open, the existing design closes. This didn't happen when I

  • MDT Media - StateStore on USB Deployment media drive?

    MDT 2012 update 1 I'm doing a Refresh (migrating XP to 7) using USB Media of my working task sequence. Everything works, migrates to 7 with all user data etc.. However I noticed it takes a very long time. There's a "StateStore" folder being created o