/rotateGUI.m

http://matlab-image-customizer.googlecode.com/ · MATLAB · 122 lines · 40 code · 23 blank · 59 comment · 3 complexity · 149e4ad7bd4acc1266057a6ec20ce2b2 MD5 · raw file

  1. function varargout = rotateGUI(varargin)
  2. % ROTATEGUI MATLAB code for rotateGUI.fig
  3. % ROTATEGUI, by itself, creates a new ROTATEGUI or raises the existing
  4. % singleton*.
  5. %
  6. % H = ROTATEGUI returns the handle to a new ROTATEGUI or the handle to
  7. % the existing singleton*.
  8. %
  9. % ROTATEGUI('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in ROTATEGUI.M with the given input arguments.
  11. %
  12. % ROTATEGUI('Property','Value',...) creates a new ROTATEGUI or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before rotateGUI_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to rotateGUI_OpeningFcn via varargin.
  17. %
  18. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
  19. % instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22. % Edit the above text to modify the response to help rotateGUI
  23. % Last Modified by GUIDE v2.5 19-Jan-2012 09:51:51
  24. % Begin initialization code - DO NOT EDIT
  25. gui_Singleton = 1;
  26. gui_State = struct('gui_Name', mfilename, ...
  27. 'gui_Singleton', gui_Singleton, ...
  28. 'gui_OpeningFcn', @rotateGUI_OpeningFcn, ...
  29. 'gui_OutputFcn', @rotateGUI_OutputFcn, ...
  30. 'gui_LayoutFcn', [] , ...
  31. 'gui_Callback', []);
  32. if nargin && ischar(varargin{1})
  33. gui_State.gui_Callback = str2func(varargin{1});
  34. end
  35. if nargout
  36. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  37. else
  38. gui_mainfcn(gui_State, varargin{:});
  39. end
  40. % End initialization code - DO NOT EDIT
  41. % --- Executes just before rotateGUI is made visible.
  42. function rotateGUI_OpeningFcn(hObject, eventdata, handles, varargin)
  43. % This function has no output args, see OutputFcn.
  44. % hObject handle to figure
  45. % eventdata reserved - to be defined in a future version of MATLAB
  46. % handles structure with handles and user data (see GUIDATA)
  47. % varargin command line arguments to rotateGUI (see VARARGIN)
  48. % Choose default command line output for rotateGUI
  49. handles.output = hObject;
  50. handles.im = varargin{1};
  51. handles.ax = varargin{2};
  52. % Update handles structure
  53. guidata(hObject, handles);
  54. % UIWAIT makes rotateGUI wait for user response (see UIRESUME)
  55. % uiwait(handles.figure1);
  56. % --- Outputs from this function are returned to the command line.
  57. function varargout = rotateGUI_OutputFcn(hObject, eventdata, handles)
  58. % varargout cell array for returning output args (see VARARGOUT);
  59. % hObject handle to figure
  60. % eventdata reserved - to be defined in a future version of MATLAB
  61. % handles structure with handles and user data (see GUIDATA)
  62. % Get default command line output from handles structure
  63. varargout{1} = handles.output;
  64. % --- Executes on slider movement.
  65. function angle_Callback(hObject, eventdata, handles)
  66. % hObject handle to angle (see GCBO)
  67. % eventdata reserved - to be defined in a future version of MATLAB
  68. % handles structure with handles and user data (see GUIDATA)
  69. % Hints: get(hObject,'Value') returns position of slider
  70. % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  71. val = get(handles.angle,'Value');
  72. set(handles.angleText,'String',val);
  73. % --- Executes during object creation, after setting all properties.
  74. function angle_CreateFcn(hObject, eventdata, handles)
  75. % hObject handle to angle (see GCBO)
  76. % eventdata reserved - to be defined in a future version of MATLAB
  77. % handles empty - handles not created until after all CreateFcns called
  78. % Hint: slider controls usually have a light gray background.
  79. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  80. set(hObject,'BackgroundColor',[.9 .9 .9]);
  81. end
  82. % --- Executes on button press in okButton.
  83. function okButton_Callback(hObject, eventdata, handles)
  84. % hObject handle to okButton (see GCBO)
  85. % eventdata reserved - to be defined in a future version of MATLAB
  86. % handles structure with handles and user data (see GUIDATA)
  87. a = get(handles.angle,'Value');
  88. handles.im = imrotate(handles.im, a);
  89. axes(handles.ax);
  90. imshow(handles.im);
  91. axis off;
  92. axis image;
  93. close rotateGUI;
  94. % --- Executes on button press in cancelButton.
  95. function cancelButton_Callback(hObject, eventdata, handles)
  96. % hObject handle to cancelButton (see GCBO)
  97. % eventdata reserved - to be defined in a future version of MATLAB
  98. % handles structure with handles and user data (see GUIDATA)
  99. close rotateGUI;