当前位置: 首页>>代码示例>>C++>>正文


C++ putpixel函数代码示例

本文整理汇总了C++中putpixel函数的典型用法代码示例。如果您正苦于以下问题:C++ putpixel函数的具体用法?C++ putpixel怎么用?C++ putpixel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了putpixel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: display_raw

int display_raw(void* data, int heigth, int width, int bsize, color_t
color)
{
	printf("bsize = %d, col=%d\n", bsize, color);
	if(SDL_Init(SDL_INIT_VIDEO) != 0){
		printf("SDL fail\n");
		return -1;
	};

	SDL_Surface *disp;

	disp = SDL_SetVideoMode(20*width,
							20*heigth,
						 32,
						 (SDL_HWSURFACE|SDL_DOUBLEBUF));

	if(!disp){
		printf("set video fail\n");
// 		return -1;
	};


	SDL_Surface *im;

	im = SDL_CreateRGBSurface(0,
							  width,
							  heigth,
						      32,
							  0,0,0,0);
	if(!im)
		printf("create fail\n");

	int x,y;
	uint8_t px[4];

	for(y=0; y<heigth; y++){
		for(x=0; x<width; x++){
			if(color == 1){
				memset(&px[1], *((uint8_t *)data), 4);
				data += bsize >> 3; //TODO this
			}
			else{
				memcpy(&px, (uint8_t *)data, 3);
				data += (bsize*color) >> 3;
			}

			putpixel(im, x, y, *(uint32_t *)px);
		}
开发者ID:karolist,项目名称:png_project,代码行数:48,代码来源:display.c

示例2: do_changetype

/* worker function for changing the type of an image */
static int do_changetype(DATAFILE *dat, int *param, int type)
{
   BITMAP *bmp;
   RLE_SPRITE *spr;
   int x, y, c, r, g, b;

   if ((dat->type != DAT_BITMAP) && (dat->type != DAT_RLE_SPRITE) &&
       (dat->type != DAT_C_SPRITE) && (dat->type != DAT_XC_SPRITE)) {
      (*param)++;
      return D_O_K;
   }

   if (dat->type == type)
      return D_O_K;

   if (dat->type == DAT_RLE_SPRITE) {
      spr = (RLE_SPRITE *)dat->dat;
      bmp = create_bitmap_ex(spr->color_depth, spr->w, spr->h);
      clear_to_color(bmp, bmp->vtable->mask_color);
      draw_rle_sprite(bmp, spr, 0, 0);
      dat->dat = bmp;
      destroy_rle_sprite(spr);
   }
   else if (type == DAT_RLE_SPRITE) {
      bmp = (BITMAP *)dat->dat;
      spr = get_rle_sprite(bmp);
      dat->dat = spr;
      destroy_bitmap(bmp);
   }
   else if ((type == DAT_C_SPRITE) || (type == DAT_XC_SPRITE)) {
      bmp = (BITMAP *)dat->dat;
      if (bitmap_color_depth(bmp) == 32) {
	 for (y=0; y<bmp->h; y++) {
	    for (x=0; x<bmp->w; x++) {
	       c = getpixel(bmp, x, y);
	       r = getr32(c);
	       g = getg32(c);
	       b = getb32(c);
	       putpixel(bmp, x, y, makecol32(r, g, b));
	    }
	 }
      }
   }

   dat->type = type;

   return D_REDRAW;
}
开发者ID:Yurand,项目名称:tw-light,代码行数:49,代码来源:datitype.c

示例3: putpixel

void bezier::detectallpt()
{
	int i,j,xcnt=0;

	int minx,miny,maxx,maxy;

	minx = maxx = ax[0];
	miny = maxy = ay[0];

	jblx = new int [cnt];
	jbly = new int [cnt];


	for(i=1;i<4;i++)
	{
		if(minx>ax[i])
			minx = ax[i];
		if(maxx<ax[i])
			maxx = ax[i];

		if(miny>ay[i])
			miny = ay[i];
		if(maxy<ay[i])
			maxy = ay[i];

	}

	for(i=miny-4;i<=479/*maxy+4*/;i++)
	{
		for(j=minx-4;j<=639/*maxx+4*/;j++)
		{
			if(WHITE == getpixel(i,j))
			{
				jblx[xcnt] = i;
				jbly[xcnt] = j;
				putpixel(i,j,YELLOW);
				xcnt++;
			}
		}
	}

	if(xcnt!=cnt)
	{
		cout<<"XCNT = "<<xcnt<<" and CNT = "<<cnt;
		getch();
	}

}
开发者ID:anirudhtomer,项目名称:UndergradCAssignments,代码行数:48,代码来源:BEZIER.CPP

示例4: circular

void circular(int h,int k,int rx,int ry,int s,int e)
{
	float angle=((s<=e)?s:e)*((M_PI)/180);
	float range=((e>s)?e:s)*((M_PI)/180);

	float x=rx*cos(angle);
	float y=ry*sin(angle);

	do{
	putpixel((int)(h+x+0.5),(int)(k-y+0.5),RED);
	angle+=0.01;
	x=rx*cos(angle);
	y=ry*sin(angle);

	}while(angle<=range);
}
开发者ID:jayantsa,项目名称:computergraphics,代码行数:16,代码来源:CIRCULAR.CPP

示例5: ffill4

void ffill4(int x,int y,int fcolor,int ocolor)
 {
          int current;
          current = getpixel(x,y);
          
          if(current == ocolor)
          {
               putpixel(x,y,fcolor);
               
                ffill4(x+1,y,fcolor,ocolor);
               ffill4(x-1,y,fcolor,ocolor);
               ffill4(x,y+1,fcolor,ocolor);
               ffill4(x,y-1,fcolor,ocolor);
               
          }
 }
开发者ID:ichlasul,项目名称:tubes-grafika,代码行数:16,代码来源:SBoard.cpp

示例6: eksplozija

void
eksplozija(int i)
{		
		int j;
		float fi;
		
		for(j=0;kratr[j]!=-1;j++)	//poisce mesto za krater
			;
		kratr[j]=kgl[i].x;		//kjer kgla pade je nov kratr
		putpixel(screen,kgl[i].dx,kgl[i].dy,0);//zbrise zadnjo kgl			
		zmaga(j);			//pogleda ce je kdo zmagu
		krater();			//narise vse kraterje
		//play_sample(blast, 255, 255-(kgl[i].x/SIRINA*255),
		//	     1000, 0); 		//bummm
		kgl[i].t=-1;			//kugla se resetira
}		
开发者ID:gto76,项目名称:tanks,代码行数:16,代码来源:process.c

示例7: boundaryFill

void boundaryFill(int x, int y, int bc, int fc)  // 4-connected (8-connected not possible)
{
	int color = getpixel(x,y);
	if((color!=bc)&&(color!=fc))
	{
		putpixel(x,y,fc);
		//delay(1);

		boundaryFill(x+1,y,bc,fc);    // right
		boundaryFill(x,y+1,bc,fc);    // top
		boundaryFill(x-1,y,bc,fc);    // left
		boundaryFill(x,y-1,bc,fc);    // bottom
	}
	else
		return;
}
开发者ID:clapslate,项目名称:CGVRS,代码行数:16,代码来源:BOUNFILL.CPP

示例8: drawchar

int drawchar(int ch, int x, int y)
{
	int i, j, maxx = 0;
	for (i = 0; i < 16; i++)
	{
		for (j = 0; j < 16; j++)
		{
			if (((char*)font->pixels)[((ch-32)*16+i)*16+j])
			{
				putpixel(x+j,y+i,0xffffffff);
				if (j > maxx) maxx = j;
			}
		}
	}
	return maxx + 1;
}
开发者ID:Fincodr,项目名称:soloud,代码行数:16,代码来源:main.cpp

示例9: bezier_test

void bezier_test(float t, int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
{
	float cx = 3 * (x1 - x0);
	float bx = 3 * (x2 - x1) - cx;
	float ax = x3 - x0 - cx - bx;
	float cy = 3 * (y1 - y0);
	float by = 3 * (y2 - y1) - cy;
	float ay = y3 - y0 - cy - by;
	float tCubed = t * t * t;
	float tSquared = t * t;
	float resultX = (ax * tCubed) + (bx * tSquared) + (cx * t) + x0;
	float resultY = (ay * tCubed) + (by * tSquared) + (cy * t) + y0;

	putpixel(screen, (int)resultX, (int)resultY, makecol(255,0,0));

}
开发者ID:tomrf,项目名称:turretz,代码行数:16,代码来源:turret.c

示例10: spline

/* spline:
 *  Draws a bezier spline onto the specified bitmap in the specified color.
 */
void spline(BITMAP *bmp, int points[8], int color)
{
   #define NPTS   64

   int xpts[NPTS], ypts[NPTS];
   int i;

   calc_spline(points, NPTS, xpts, ypts);

   for (i=1; i<NPTS; i++) {
      line(bmp, xpts[i-1], ypts[i-1], xpts[i], ypts[i], color);

      if (_drawing_mode == DRAW_MODE_XOR)
	 putpixel(bmp, xpts[i], ypts[i], color);
   }
}
开发者ID:ifilex,项目名称:SRC,代码行数:19,代码来源:spline.c

示例11: DrawSphere

void DrawSphere(SDL_Surface* screen, Sphere s, int width, int height, LightSource light)
{
	for (int x=0;x<width;x++) for (int y=0;y<height;y++)
	{
		if (x>width/2+70) if (y>height/2+20) 
			s=s;
		Vector sol = Solution(Vector(x-width/2,1000,y-height/2),Vector(0,0,0),s);
		if (sol!=Vector(0,0,0))
		{
			Color c1=s.color_;
			putpixel(screen,x,y,Shadow(light,sol,s).GetUint32());
			SDL_UpdateRect(screen,x,y,1,1);
		}
	}
	//SDL_UpdateRect(screen,0,0,1024,600);
}
开发者ID:niggin,项目名称:test-sdl-ray-tracing,代码行数:16,代码来源:test_one.cpp

示例12: main

// int main (int argc, char **argv)
void main ()
{
	int x,y;
	for (y=128;y<256;++y) {
		for (x=0;x<320;++x) {
			#define scry (y-127)
			#define scrx (x-160)
			int wz = PLANE_DEPTH * FOCAL_DIST / scry;
			// int wx = scrx * wz / FOCAL_DIST;
			int wx = PLANE_DEPTH * scrx / scry;
			// putpixel(x,y,1 + ((abs(wx/GRID_SIZE)+wz/GRID_SIZE)%2));
			putpixel(x, y, ( ((wx/GRID_SIZE)&3) == 2 ? 1 : 0 ) + ( ((wz/GRID_SIZE)&3) == 0 ? 2 : 0 ) );
			// putpixel(x,y,1 + (((wx+wz) >> 5) & 1)); // not working right
		}
	}
}
开发者ID:crtc-demos,项目名称:the-master-of-your-old-school,代码行数:17,代码来源:test.c

示例13: setcolor

void ghost::drawghost(int x,int y)
{
	int i;

	setcolor(DARKGRAY);
	setfillstyle(SOLID_FILL,DARKGRAY);

	//head

	circle(x,y,r);
	fillellipse(x,y,r,r);  // to fill the head of ghost

	//body frame
	for(i=x-r/2;i<=x+r/2;i++)  // "i" is the vertical line being chosen (x coordinate)
	{
		line(i,y+r,i,y+r+lb);
	}

	//right arm       ....16 pixels down from the head
	for(i=0;i<wa;i++)     // "i" is the lateral line being chosen (y coordinate)
	{
		line(x+r/2,y+i+16,x+r/2+la,y+i+24);
	}

	//left arm      .... 16 pixels down from the head
	for(i=0;i<wa;i++)     // "i" is the lateral line being chosen (y coordinate)
	{
		line(x-r/2,y+i+16,x-r/2-la,y+i+24);
	}

	//right leg     ....4 pixels above the bottom of the body
	for(i=0;i<wl;i++)
	{
		line(x,y+r+lb+i-8,x+ll,y+r+lb+i+10);
	}

	//left leg     ....4 pixels above the bottom of the body
	for(i=0;i<wl;i++)
	{
		line(x,y+r+lb+i-8,x-ll,y+r+lb+i+10);
	}

	//eyes
	putpixel(x-r/2,y-r/2,LIGHTGRAY);
	putpixel(x+r/2,y-r/2,LIGHTGRAY);
	putpixel(x-r/2-1,y-r/2,LIGHTGRAY);
	putpixel(x+r/2+1,y-r/2,LIGHTGRAY);
	putpixel(x-r/2,y-r/2+1,LIGHTGRAY);
	putpixel(x+r/2,y-r/2+1,LIGHTGRAY);

	//to draw the nose
	setcolor(LIGHTGRAY);
	line(x,y-2,x,y+2);

}
开发者ID:anirudhtomer,项目名称:UndergradCAssignments,代码行数:55,代码来源:half_ghost_kill+(not+yet+ready).CPP

示例14: draw_julia

//draw julia set
void draw_julia(Screen* screen) {
	//each iteration, we calculate: new = old * old + c
	//c is constant
	//old starts at current pixel
	double cRe, cIm; //real and imaginary parts of c
	double new_re, new_im, old_re, old_im; //real and imaginary parts of new and old
	double zoom = 1, move_x = 0, move_y = 0;
	int max_iterations = 300; 

	//pick some values for constant c
	//determines shape
	//cRe = -0.7;
	cRe = -0.7;
	//cIm = 0.27015;
	cIm = -0.61841;

	int w = screen->window->size.width;
	int h = screen->window->size.height;

	//for every pixel
	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			//calculate real and imaginary part of z
			//based on pixel location and zoom and position values
			new_re = 1.5 * (x - w / 2) / (0.5 * zoom * w) + move_x;
			new_im = (y - h / 2) / (0.5 * zoom * h) + move_y;
			
			int i;
			for (i = 0; i < max_iterations; i++) {
				//remember value of previous iteration
				old_re = new_re;
				old_im = new_im;

				//the actual iteration, real and imaginary part are calculated
				new_re = old_re * old_re - old_im * old_im + cRe;
				new_im = 2 * old_re * old_im + cIm;

				//if point is outside the circle with radius 2: stop
				if ((new_re * new_re + new_im * new_im) > 4) break;
			}

			//Color color = color_make(180 * (i % max_iterations), 20 * (i % max_iterations), 100 * (i % max_iterations));
			Color color = color_make(i % max_iterations + 2, 0, 0);
			putpixel(screen, x, y, color);
		}
	}
}
开发者ID:Haifisch,项目名称:axle,代码行数:48,代码来源:gfx_test.c

示例15: writechar

void writechar (int x, int y, char c, int cl)
{
  register int idx;
  register unsigned char *_font = (unsigned char*) &font[c-' '][0];
  XSetForeground(dis,gc,egacolors[cl]);
  for (idx=0; idx<8; idx++) {
    register unsigned char w = _font[idx];
    register unsigned int yidx = y+idx;
    if (w&128) putpixel (x+0, yidx);
    if (w&64)  putpixel (x+1, yidx);
    if (w&32)  putpixel (x+2, yidx);
    if (w&16)  putpixel (x+3, yidx);
    if (w&8)   putpixel (x+4, yidx);
    if (w&4)   putpixel (x+5, yidx);
    if (w&2)   putpixel (x+6, yidx);
    if (w&1)   putpixel (x+7, yidx);
  }
}
开发者ID:mribelotta,项目名称:oneshot,代码行数:18,代码来源:fontm.cpp


注:本文中的putpixel函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。