Print an image in Matlab GUI

How do you print an image from a printer in Matlab GUI? I get an error using the code below. Please help me.
Undefined function or variable 'smapleimage'.
smapleimage = imread('image.png');
printdlg(handles.smapleimage)

回答 (1 件)

Arthur
Arthur 2012 年 11 月 17 日

0 投票

I guess it should be
smapleimage = imread('image.png');
printdlg(smapleimage)

6 件のコメント

Eric Letsolo
Eric Letsolo 2012 年 11 月 17 日
it returns an error message. Error using cellfun Non-scalar in Uniform output, at index 1, output 1. Set 'UniformOutput' to false.
Arthur
Arthur 2012 年 11 月 17 日
This error does not come from the two lines you showed here. Please show the entire error message, and the code where it came from.
Eric Letsolo
Eric Letsolo 2012 年 11 月 17 日
編集済み: Image Analyst 2012 年 11 月 18 日
This is the code
function Print_Callback(hObject, eventdata, handles)
smapleimage = imread('d.png');
printdlg(smapleimage)
Error using cellfun
Non-scalar in Uniform output, at index 1, output 1.
Set 'UniformOutput' to false.
Error in printdlg (line 13)
idx = cellfun(@(X) any(ishghandle(X,'figure')), varargin);
Error in AMNR>Print_Callback (line 535)
printdlg(smapleimage)
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in AMNR (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)AMNR('Print_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Arthur
Arthur 2012 年 11 月 17 日
Ok, printdlg only accepts figure windows. Try this:
hFig = figure();
smapleimage = imread('image.png');
imshow(smapleimage)
printdlg(hFig)
Eric Letsolo
Eric Letsolo 2012 年 11 月 17 日
I can print a figure using printdlg(handles.Fig) Is it possible to print out an image from Matlab GUI
Arthur
Arthur 2012 年 11 月 18 日

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

質問済み:

2012 年 11 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by