Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C by Lester Vecsey ( 13 years ago )
/*
A simple RGB example (formula plot) for use with image display program.
Copyright (C) <2013> <Lester Vecsey>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact via [email protected] or mail to 700 Jane Dr, Franklin Lakes,
NJ, 07417
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
int main(int argc, char *argv[]) {
long int xres = 960, yres = 960;
size_t img_sz = xres*yres*sizeof(u_int16_t)*3;
u_int16_t *rgb = malloc(img_sz);
long int n;
double f(double x) {
return 1.0 / (1.0 + x);
}
long int xpos, ypos;
double x,y;
for (xpos=0; xpos < xres; xpos++) {
x = xpos-xres/2;
x *= 6.0;
x /= xres;
y = f(x);
ypos = y;
ypos += yres/2;
rgb[ypos*xres*3+xpos*3+0] = 65535;
rgb[ypos*xres*3+xpos*3+1] = 65535;
rgb[ypos*xres*3+xpos*3+2] = 65535;
}
write(1,rgb,img_sz);
return 0;
}
Revise this Paste