代码: 全选
#include <stdio.h>
#include <time.h>
#include <math.h>
#define IMAGE_WIDTH 1000
#define IMAGE_HEIGHT 1000
guchar *pos;
guchar rgbbuf[IMAGE_WIDTH * IMAGE_HEIGHT * 3];
int main()
{
gint x,y;
pos = rgbbuf;
gdouble vx,vy;
guchar bright= 0;
GTimeVal timestart;
g_get_current_time(×tart);
for (y = 0; y< IMAGE_HEIGHT;y++)
{
vx=0;
vy=0;
gdouble tmpy = ((256-bright)/(gdouble)IMAGE_HEIGHT)*((gdouble)y);
for (x= 0; x<IMAGE_WIDTH; x++)
{
vx +=(256-bright)/(gdouble)IMAGE_WIDTH;
vy += (tmpy)/IMAGE_WIDTH;
guchar r,g,b;
r = floor(vx);
g = floor(vy);
b = floor(vy);
*pos++ =r; /*Red. */
*pos++ =g; /*Green. */
*pos++ =b; /*Blue. */
}
}
GTimeVal timeend;
g_get_current_time(&timeend);
glong lostTime = timeend.tv_usec - timestart.tv_usec;
g_print("The Calendar Time lost %d\n", lostTime);
return (0);
}