00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "mex.h"
00018
00019 #define RED 0
00020 #define GREEN 1
00021 #define BLUE 2
00022
00023 void mexFunction(int nlhs, mxArray *plhs[], int nrhs,
00024 const mxArray *prhs[])
00025 {
00026 double handle;
00027 const mxArray *color_array_ptr;
00028 mxArray *value;
00029 double *color;
00030
00031 (void) plhs;
00032
00033
00034
00035
00036 if(nrhs != 1 || !mxIsDouble(prhs[0])){
00037 mexErrMsgTxt("Must be called with a valid handle");
00038 }
00039
00040 if(nlhs > 1){
00041 mexErrMsgTxt("Too many output arguments.");
00042 }
00043
00044
00045 if (mxGetN(prhs[0]) != 1 || mxGetM(prhs[0]) !=1){
00046 mexErrMsgTxt("Input must be a scalar handle value.\n");
00047 }
00048
00049 handle = mxGetScalar(prhs[0]);
00050
00051
00052 color_array_ptr = mexGet(handle, "Color");
00053 if (color_array_ptr == NULL)
00054 mexErrMsgTxt("Could not get this handle property");
00055
00056
00057 value = mxDuplicateArray(color_array_ptr);
00058
00059
00060
00061 color = mxGetPr(value);
00062
00063
00064 color[RED] = (1 + color[RED]) /2;
00065 color[GREEN] = color[GREEN]/2;
00066 color[BLUE] = color[BLUE]/2;
00067
00068
00069 if(mexSet(handle, "Color", value))
00070 mexErrMsgTxt("Could not set a new 'Color' property.");
00071 }
00072
00073
00074