We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › read arrays created in c/c++
Page Index Toggle Pages: 1
read arrays created in c/c++ (Read 481 times)
read arrays created in c/c++
Feb 10th, 2006, 10:57am
 
Hello,
I have some 2D et 3D (float)arrays created by fwrite() function of the c/c++. I want to read them correctly by processing  for the visualization. But I  have  found  only
loadbyte() function who doesn't work as I want.

Is there anyone who can give me some propositions?
Thank you so much...
Re: read arrays created in c/c++
Reply #1 - Feb 23rd, 2006, 3:11pm
 
byte b[] = loadBytes("float1.dat");

 

float[][][] numbers  = new float[N][N][N];
//depends on dimension you use

for (int i = 0; i < b.length; i+=4) {  
int bitPattern = (0x000000ff & (b[i+3] << 0)) | ( 0x0000ff00 & (b[i+2] << 8) ) | (
 0x00ff0000 & (b[i+1] << 16) ) |  (b[i] << 24) ;


 float a = Float.intBitsToFloat(bitPattern);

 if(i==0){
 print(b.length +  " ");
 println();

}
//then you can put the variable "a" in a 3D array to use as //you want
}


byes
Page Index Toggle Pages: 1