• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ putpixel函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: image_draw

void image_draw(int color, int iterations) {
	int px, py;
	
	x = 0;
	y = 0;
	for (i = 1; i <= iterations; i++) {
		j = (rand() % 32767);
		k = (j < p[0]) ? 0 :((j < p[1]) ? 1 : ((j < p[2]) ? 2 : 3));
		newx = (a[k]*x + b[k]*y + e[k]);
		y = (c[k]*x + d[k]*y + f[k]);
		x = newx;
		px = x*xscale + xoffset;
		py = (480 - y*yscale + yoffset);
		if ((px >= 0) && (px < 640) && (py >= 0) && (py < 480))
			putpixel(px, py, color);
	}
}
开发者ID:danielgrimshaw,项目名称:Fractals,代码行数:17,代码来源:image.c


示例17: set_strengthright

int set_strengthright(int first) {
    static int angle=0,i,j,flag=1;
    if (first==0) {
        angle = 0;
        flag = 1 ;
        for (i=ps[1]; i<=ps[1]+length; i++)
            for (j=0; j<=CL; j++)     putpixel(i, PY+j, BLACK);
    }
    while (!bioskey(1)) {
        angle+=flag;
        if (angle==89)  flag=-1;
        if (angle==0 )  flag=1;
        draw_strengthR(angle,flag);
        for (i=0; i<80000; i++)delay(0.99999999999999994);
    }
    return angle;
}
开发者ID:quheng,项目名称:fruit,代码行数:17,代码来源:key.c


示例18: draw_stars

static void draw_stars (SDL_Rect * cam, SDL_Rect * targ)
{
    int r, x, y;
    Uint8 *col;
    for (r = 0; r < sizeof(lev_stars)/sizeof(Star); r++) {
        x = cam->x + lev_stars[r].x;
        y = cam->y + lev_stars[r].y;
        col =
            (Uint8 *) lev_level.terrain->pixels +
            y * lev_level.terrain->pitch +
            x * lev_level.terrain->format->BytesPerPixel;
        if (x < lev_level.width && y < lev_level.height)
          if (lev_level.solid[x][y] == TER_FREE && col[0] < 5 && col[1] < 5 && col[2] < 5)
            putpixel (screen, targ->x + lev_stars[r].x,
                      targ->y + lev_stars[r].y, col_white);
    }
}
开发者ID:callaa,项目名称:luola,代码行数:17,代码来源:level.c


示例19: drawship

static void
drawship(int x, int y) {
    int u, v;
    char c;

    x -= 8;
    y -= 8;

    for (u = 0; u < 16; u++)
        for (v = 0; v < 16; v++) {
            c = ship[u][v];

            /* transparency */
            if (c != 0)
                putpixel(u + x, v + y, c, virt);
        }
}
开发者ID:dlundquist,项目名称:lunar,代码行数:17,代码来源:lunar.c


示例20: movemissile

void movemissile()
{     
     samExplosion2 = load_sample("C:\\Sanchit\\Game Pack\\Sprites\\explosion2.wav");
 
     int x = points[curpoint].x ;
     int y = points[curpoint].y ;
 
     scare_mouse();

     rectfill(buffer,x-6,y-3,x+6,y+1,BLACK);

     if (getpixel(screen,x,y) == GREEN)
     {  
            destroyed++;
            updatescore();
            rectfill(buffer, 2, 14, 636, 352, BLACK);
     }
     else
     {
          putpixel(buffer,x,y-3,SMOKE);
          circlefill(buffer,x,y,2,BLUE);
     }
         
     unscare_mouse();
     
     curpoint++;
     if (curpoint >= totalpoints)
     {        
          play_sample(samExplosion2, 128, 128, 1000, 0);
          destroyed++;

          explosion2(screen, x, y, BLACK);

          textout_ex( screen, font, "Game Over", 300, 230, makecol( 255, 0, 0), makecol( 0, 0, 0));       
          rest(2000);
          textprintf(screen,font,300,245,makecol(255,255,255), "Final Score=%d", score);
          rest(2000);
          
          stop_sample(samSong);
          stop_sample(samExplosion2);
          
          score=-1;
          
          openscreen();
     }
}
开发者ID:sanchit234,项目名称:GamePack,代码行数:46,代码来源:savecity.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ putq函数代码示例发布时间:2022-05-30
下一篇:
C++ putpad函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap