addLogo - add image to container figure/panel

add the specified image at the specified container position; supports resizing/animated/transparent
775 Downloads
Updated 8 Jul 2013

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.

Cite As

Yair Altman (2024). addLogo - add image to container figure/panel (https://www.mathworks.com/matlabcentral/fileexchange/42400-addlogo-add-image-to-container-figure-panel), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags
gui

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.2.0.0

Fix for files on current folder

1.0.0.0