Skip to content

Commit

Permalink
Cache transparent image.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBColton committed Nov 13, 2014
1 parent c00edb3 commit 256f932
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion org/lateralgm/resources/library/LibAction.java
Expand Up @@ -29,6 +29,8 @@ public class LibAction
//control remove the transparent color when rendering. This allows the action to be written back without
//the transparency removed.
public boolean useTransparencyKey = false;
private BufferedImage transparentImage = null; // cached version of the image with transparency

public int id = 0;
public int parentId = -1; //Preserves the id when library is unknown
public Library parent = null;
Expand Down Expand Up @@ -78,7 +80,7 @@ public boolean equals(Object obj)
}

public BufferedImage getImage() {
return (useTransparencyKey ? Util.getTransparentImage(actImage) : actImage);
return (useTransparencyKey ? (transparentImage == null ? transparentImage = Util.getTransparentImage(actImage) : transparentImage) : actImage);
}

}

0 comments on commit 256f932

Please sign in to comment.