; docformat = 'rst' ;+ ; Convert RGB coordinates of colors to the ; ; :Returns: ; lonarr ; ; :Params: ; rgb : in, required, type=bytarr ; either bytarr(3) or bytarr(n, 3) array of RGB coordinates of colors ;- function mg_rgb2index, rgb compile_opt strictarr on_error, 2 if (n_elements(rgb) lt 3L) then message, 'not enough elements in RGB array' ndims = size(rgb, /n_dimensions) case ndims of 1: return, rgb[0] + rgb[1] * 2L^8 + rgb[2] * 2L^16 2: return, rgb[*, 0] + rgb[*, 1] * 2L^8 + rgb[*, 2] * 2L^16 else: message, 'invalid number of dimensions for RGB array' endcase end