File Exchange

image thumbnail

addLogo - add image to container figure/panel

version 1.2 (3.33 KB) by

add the specified image at the specified container position; supports resizing/animated/transparent

1 Download

Updated

View License

Syntax:
hPanel = addLogo(filename,pixelPosition,hContainer)

Description:
addLogo(filename) adds the image specified by filename to the top-left position in the current figure.

All the standard image types recognized in modern browsers (HTML) are accepted, including GIF, JPG and PNG. Animated GIFs and transparent images are also accepted. Note that transparent images will show the container's background, but not any axes or control that lie between the container and the image.

addLogo(filename,pixelPosition) adds the image to the current figure, at the position specified by pixelPosition. Both relative and absolute positions are supported, as well as image resizing.

addLogo(filename,pixelPosition,hContainer) adds the image to the specified container, which is a handle to a figure/panel/etc.

Inputs:
- filename (mandatory): name of logo image file (full or relative path)

- pixelPosition (optional): position in parent container: [X,Y,W,H]
default value = [1,0,0,0], i.e. top-left corner of container
empty pixelPosition ([]) means to use the default value (=[1,0,0,0])
X value can be <=0, meaning left from container's right edge
Y value can be <=0, meaning below container's top edge
Width/Height values are optional (default=0)
Width/Height values can be 0, meaning the image's actual width/height
Width/Height values can be negative, meaning resized from image size
Width/Height values can be positive, meaning resized to specified size
[1,0,0,0] = top-left corner of container (default value)
[1,1,0,0] = bottom-left corner of container
[0,0,0,0] = top-right corner of container
[0,1,0,0] = bottom-right corner of container

- hContainer (optional): handle to parent container. default=gcf

Outputs:
- hPanel - handle to panel containing the image (can be resized/deleted/etc.)

Example:
addLogo('image.jpg'); % add image at top-left of current figure
addLogo('image.jpg',[]); % same as above
addLogo('image.jpg',[1,0]); % same as above
addLogo('image.jpg',[1,0,0,0],gcf); % same as above

addLogo('logo.png',[0,1]); % add image at bottom-right of current figure
addLogo('logo.png',[90,230]); % add image at position X=90, Y=230
addLogo('logo.png',[90,230,50,85]); % add 50x85 resized image at 90,230

addLogo('abc.gif',[-10,-10,50,85]); % add 50x85 resized image at top-right

addLogo('abc.gif',[],hPanel); % add at top-left of containing hPanel

Technical Description:
See http://UndocumentedMatlab.com/blog/displaying-animated-gifs

Bugs and suggestions:
Please send to Yair Altman (altmany at gmail dot com)

Limitations:
In some cases Matlab may require the containing figure to be visible for addLogo to work. This is not always the case, so check this issue on your specific platform / application.

Comments and Ratings (0)

Updates

1.2

Fix for files on current folder

MATLAB Release
MATLAB 7.11 (R2010b)
Tags Add Tags
gui

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video