Forums > Java

[BUG] CopyMatrixtoArray is signed instead of "char"

June 11, 2008 | 3:54 pm

Hi,

it seems that the result of CopyMatrixtoArray() change the "char" values (0-255) to something signed… (but not CopyVectortoArray())

The picture attached below shows what happens, testing for the color of somes pixels :
-with the CopyMatrixtoArray() method in the first tens lines of the max window,
-and with the CopyVectortoArray() method in the tens lines after.

best,
Alexandre


June 11, 2008 | 4:03 pm

here is the java code and the patch to reproduice :

import com.cycling74.max.*;
import com.cycling74.jitter.*;

public class testttttttttt extends MaxObject {
testttttttttt (Atom[] a) {
declareInlets(new int[]{DataTypes.ALL});
declareOutlets(new int[]{DataTypes.ALL,DataTypes.ALL,DataTypes.ALL,
DataTypes.ALL,DataTypes.ALL,DataTypes.ALL,DataTypes.ALL,DataTypes.ALL});
createInfoOutlet(false);
}

JitterMatrix jm = new JitterMatrix();

public void jit_matrix(String s)
{
jm.frommatrix(s);
int dim[] = jm.getDim();
int planecount = jm.getPlanecount();
int offset[] = new int[]{0,0};
int row[] = new int[dim[0]*planecount*dim[1]];

// jm.copyVectorToArray(0, offset, row, dim[0]*planecount*dim[1], 0);
jm.copyMatrixToArray(row);

outlet(0, "ARRAY : ", row );
outlet(0, "FIRST ROW : ");
outlet(0, "test white :", new int[]{ row[1] , row[2],row[3] } );
outlet(0, "test red :", new int[]{ row[33] , row[34],row[35] } );
outlet(0, "test blue :", new int[]{ row[37] , row[38],row[39] } );
outlet(0, "test magenta", new int[]{ row[29] , row[30],row[31] } );
outlet(0, "EIGHTH ROW : ");
outlet(0, "test blue :", new int[]{ row[281] , row[282],row[283] } );
outlet(0, "test blue :", new int[]{ row[285] , row[286],row[287] } );
outlet(0, "test black :", new int[]{ row[289] , row[290],row[291] } );
}

}

*****************************************************************

{
"boxes" : [ {
"box" : {
"maxclass" : "newobj",
"text" : "print",
"patching_rect" : [ 1163.0, 116.0, 33.0, 20.0 ],
"fontsize" : 11.595187,
"numinlets" : 1,
"fontname" : "Arial",
"numoutlets" : 0,
"id" : "obj-111"
}

}
, {
"box" : {
"maxclass" : "button",
"outlettype" : [ "bang" ],
"patching_rect" : [ 1007.0, 23.0, 47.0, 47.0 ],
"numinlets" : 1,
"numoutlets" : 1,
"id" : "obj-79"
}

}
, {
"box" : {
"maxclass" : "jit.pwindow",
"outlettype" : [ "", "" ],
"patching_rect" : [ 1016.0, 140.0, 224.0, 225.0 ],
"onscreen" : 0,
"depthbuffer" : 463945120,
"numinlets" : 1,
"numoutlets" : 2,
"id" : "obj-85",
"doublebuffer" : 0
}

}
, {
"box" : {
"maxclass" : "message",
"text" : "importmovie colorbars.pict",
"outlettype" : [ "" ],
"patching_rect" : [ 1073.0, 30.0, 167.0, 18.0 ],
"fontsize" : 11.595187,
"numinlets" : 2,
"fontname" : "Arial",
"numoutlets" : 1,
"id" : "obj-86"
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "jit.matrix 4 char 10 10",
"outlettype" : [ "jit_matrix", "" ],
"patching_rect" : [ 1072.0, 57.0, 138.0, 20.0 ],
"fontsize" : 11.595187,
"numinlets" : 1,
"fontname" : "Arial",
"numoutlets" : 2,
"id" : "obj-87"
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "mxj testttttttttt",
"outlettype" : [ "", "", "", "", "", "", "", "" ],
"patching_rect" : [ 1097.0, 88.0, 113.5, 20.0 ],
"fontsize" : 11.595187,
"numinlets" : 1,
"fontname" : "Arial",
"numoutlets" : 8,
"id" : "obj-76"
}

}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-79", 0 ],
"destination" : [ "obj-87", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-87", 0 ],
"destination" : [ "obj-85", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-86", 0 ],
"destination" : [ "obj-87", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-87", 0 ],
"destination" : [ "obj-76", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-76", 0 ],
"destination" : [ "obj-111", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
]
}


Viewing 2 posts - 1 through 2 (of 2 total)