Skip to content

Commit de5c929

Browse files
fix issue #283
1 parent f7d8f24 commit de5c929

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Diff for: plotly/plotlyfig_aux/handlegraphics/updateImage.m

+10-4
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@
8787
%-------------------------------------------------------------------------%
8888

8989
%-image z-%
90-
if(size(image_data.CData,3) > 1)
91-
% TODO: ALLOW FOR TRUE COLOUR SPECS.
92-
obj.data{imageIndex}.z = cdata(:,:,1);
90+
isrgbimg = (size(image_data.CData,3) > 1);
91+
92+
if isrgbimg
93+
[IND,colormap] = rgb2ind(cdata, 256);
94+
obj.data{imageIndex}.z = IND;
9395
else
9496
obj.data{imageIndex}.z = cdata;
9597
end
@@ -137,7 +139,11 @@
137139
%-COLORSCALE (ASSUMES IMAGE CDATAMAP IS 'SCALED')-%
138140

139141
%-image colorscale-%
140-
colormap = figure_data.Colormap;
142+
143+
if ~isrgbimg
144+
colormap = figure_data.Colormap;
145+
end
146+
141147
len = length(colormap) - 1;
142148

143149
for c = 1:size(colormap, 1)

0 commit comments

Comments
 (0)