2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2011-2012 - DIGITEO - Pierre Lando
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 #include "DecompositionUtils.hxx"
14 #include "MatPlotDecomposer.hxx"
15 #include "DataProperties.hxx"
16 #include "ColorComputer.hxx"
20 #include "getGraphicObjectProperty.h"
21 #include "graphicObjectProperties.h"
24 int MatPlotDecomposer::getTextureWidth(char* id)
27 int* piWidth = &width;
28 getGraphicObjectProperty(id, __GO_DATA_MODEL_NUM_X__, jni_int, (void**) &piWidth);
33 int MatPlotDecomposer::getTextureHeight(char* id)
36 int* piHeight = &height;
37 getGraphicObjectProperty(id, __GO_DATA_MODEL_NUM_Y__, jni_int, (void**) &piHeight);
42 int MatPlotDecomposer::fillTextureData(char* id, unsigned char* buffer, int bufferLength)
45 getGraphicObjectProperty(id, __GO_DATA_MODEL_Z__, jni_double_vector, (void**) &value);
46 int textureWidth = getTextureWidth(id);
47 int textureHeight = getTextureHeight(id);
48 int dataSize = textureWidth * textureHeight;
49 if (dataSize * 4 == bufferLength)
52 char* parentFigure = NULL;
53 double* colormap = NULL;
55 int* piColormapSize = &colormapSize;
57 getGraphicObjectProperty(id, __GO_PARENT_FIGURE__, jni_string, (void**) &parentFigure);
58 getGraphicObjectProperty(parentFigure, __GO_COLORMAP__, jni_double_vector, (void**) &colormap);
59 getGraphicObjectProperty(parentFigure, __GO_COLORMAP_SIZE__, jni_int, (void**) &piColormapSize);
61 for (int i = 0 ; i < textureWidth ; i++)
63 for (int j = 0 ; j < textureHeight ; j++)
65 ColorComputer::getDirectByteColor(value[j + i * textureHeight] - 1, colormap, colormapSize, &buffer[4 * (i + j * textureWidth)], false);
78 int MatPlotDecomposer::fillTextureData(char* id, unsigned char* buffer, int bufferLength, int x, int y, int width, int height)
81 getGraphicObjectProperty(id, __GO_DATA_MODEL_Z__, jni_double_vector, (void**) &value);
82 if (width * height * 4 == bufferLength)
84 char* parentFigure = NULL;
85 double* colormap = NULL;
87 int* piColormapSize = &colormapSize;
88 getGraphicObjectProperty(id, __GO_PARENT_FIGURE__, jni_string, (void**) &parentFigure);
89 getGraphicObjectProperty(parentFigure, __GO_COLORMAP__, jni_double_vector, (void**) &colormap);
90 getGraphicObjectProperty(parentFigure, __GO_COLORMAP_SIZE__, jni_int, (void**) &piColormapSize);
91 int textureHeight = getTextureHeight(id);
93 for (int j = y ; j < y + height ; j++)
95 for (int i = x ; i < x + width ; i++)
97 ColorComputer::getDirectByteColor(value[j + i * textureHeight] - 1, colormap, colormapSize, &buffer[k]);