Originally Posted by
flp1969
PPM (binary) Graphics format:
P6
width height
max-value-per-component
<binary data> (RR GG BB RR GG BB ...)
The first 3 lines are strings
Example:
P6
1024 1024
255
FF FF FF 80 23 4D ... (binary)
You must have 1024*1024 bytes in binary to match the width and height.
You can change P6 to P3 and write RR GG BB in decimal string:
P3
1024 1024
255
255 255 255
128 34 77
... (strings)
See [utl=https://en.wikipedia.org/wiki/Netpbm_format]netpbm format[/url]
thank you that worked
Used this:
Code:
uint mcc___rnd( uint *seed ) {
/* Initial random value */
uint _seed;
char tseed[10] = "946853721";
struct timespec ts;
clock_gettime(CLOCK_REALTIME,&ts);
_seed = ((ulong)&_seed + ts.tv_nsec + (ts.tv_nsec << 1)) *
tseed[ts.tv_nsec%10];
if ( !seed ) seed = &_seed;
return _seed + (tseed[*seed%10] * tseed[_seed%10] * _seed);
}
Gave me noisy result (with some slight tears) despite it failing the dieharder tests
Code:
#ifdef HARDY_RND
int main() {
uint val;
while ( 1 ) {
val = mcc___rnd( NULL );
fwrite( &val, 4, 1, stdout );
}
return 0;
}
#elif defined( NOISY_RND )
#define PER_LOOP 1024
long double rand2rgb( uint n ) {
long double f = n;
return (f * 16777215.0L);
}
int main() {
int x, y;
uint val;
char *header = "P6\n1024 1024\n255\n";
fwrite(header,strlen(header),1,stdout);
for ( x = 0; x < PER_LOOP; ++x ) {
for ( y = 0; y < PER_LOOP; ++y ) {
val = mcc___rnd( NULL );
fwrite( &val, 4, 1, stdout );
}
}
return 0;
}
#else
Gotts leave for work now so don't have time to look through posts for how to downsize image for uploading