MATLAB inverts colors in uicontrol objects

I wrote a GUI application but my problem is that when I save the figure programatically using the saveas command, colors of the uicontrol objects seem to be inverted. The MATLAB Documentation says that inversion only applies to figures, not uicontrols. But here it is not the case. Does anybody have an idea?
Thanks,
Zoli

9 Comments

What kind of format are you saving the object as?
If you are looking at the figure InvertHardcopy property, note that it says,
When InvertHardCopy is on, MATLAB eliminates this effect by changing the color of the figure and axes to white and the axis lines, tick marks, axis labels, etc., to black. lines, text, and the edges of patches and surfaces might be changed, depending on the print command options specified.
which is more than just "figures". uicontrols are potentially covered under the "etc."
But I did this:
set(gcf, 'InvertHardCopy', 'off'),
and it still inverts.
Please show your saveas() command.
function saveAs(varargin)
prompt = 'Filename (extension recommended)';
dialogTitle = 'Save';
numberOfLines = 1;
defaultAnswer = {'CurrentFigure.bmp'};
fileName = inputdlg(prompt, dialogTitle, numberOfLines, defaultAnswer);
if ~isempty(fileName)
try
saveas(gca,fileName{1}); % somehow it does not save the axes,
% it captures the whole figure
catch exception % if an error occurs
if (strcmp(exception.identifier,'MATLAB:saveas:invalidFilename'))
errorstring = sprintf('%s', ...
'You have no writing permission into ', fileName{1});
errordlg(errorstring, 'Error during saving');
else
rethrow(exception);
end
end
end
end
It is my function that uses the saveas command. Before it, I set the 'InvertHardCopy' property to 'off', as you can see in my previous comment.
As a test, at the command line command
IHC = get(0, 'DefaultFigureInvertHardcopy')
set(0, 'DefaultFigureInvertHardcopy', 'false');
Then try again. When you finish, set() the value back to whatever came out in IHC
Command
get(0, 'DefaultFigureInvertHardcopy')
displays 'on', but using
set(0, 'DefaultFigureInvertHardcopy', 'false');
creates an error: "Bad property value found".
should be 'off' instead of 'false'
Sorry try 'off' instead of 'false'
I tried it but failed. I mean the colour of the uicontrol objects were converted to light green instead of grey. Could you please try my saveAs function on your machine with a custom figure with a pushbutton on it? Perhaps you will exactly know what I'm thinking of. Thank you for your help so far.

Sign in to comment.

Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Asked:

on 15 Sep 2013

Community Treasure Hunt

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

Start Hunting!