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


C++ PutPixel函数代码示例

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


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

示例1: drawLine

void drawLine(int x1, int y1, int x2, int y2) {
    const int deltaX = abs(x2 - x1);
    const int deltaY = abs(y2 - y1);
    const int signX = x1 < x2 ? 1 : -1;
    const int signY = y1 < y2 ? 1 : -1;
    //
    int error = deltaX - deltaY;
		int error2;
    //
    PutPixel(x2, y2);
    while(x1 != x2 || y1 != y2) {
        PutPixel(x1, y1);
        error2 = error * 2;
        //
        if(error2 > -deltaY) {
            error -= deltaY;
            x1 += signX;
        }
        if(error2 < deltaX) {
            error += deltaX;
            y1 += signY;
        }
    }
 
}
开发者ID:tarasii,项目名称:BMP085,代码行数:25,代码来源:ext_glcd.c

示例2: Display_DrawRect_If

inline void Display_DrawRect_If(uint32_t xs, uint32_t xe, uint32_t ys, uint32_t ye, uint16_t colour)
{
	volatile uint32_t n;

	if((xe < xs) || (ye < ys) ) return;

	n = xe - xs;
	do{
		PutPixel((xe-n),ys,colour);
	} while (n--);

	n = xe - xs;
	do{
		PutPixel((xe-n),ye,colour);
	} while (n--);

	n = ye - ys;
	do{
		PutPixel(xs,(ye-n),colour);
	} while (n--);

	n = ye - ys;
	do{
		PutPixel(xe,(ye-n),colour);
	} while (n--);
	
}
开发者ID:PascalSI,项目名称:STM32Primer2_GPS_Tracker,代码行数:27,代码来源:display_if_support.c

示例3: glider

void glider(u8 x,u8 y){
	PutPixel(x+1,y,1,0);
	PutPixel(x+2,y+1,1,0);
	PutPixel(x  ,y+2,1,0);
	PutPixel(x+1,y+2,1,0);
	PutPixel(x+2,y+2,1,0);
}
开发者ID:Aliandrana,项目名称:uzebox,代码行数:7,代码来源:gameoflife.c

示例4: rPentamino

void rPentamino(u8 x,u8 y){

	PutPixel(x+1,y,1,0);
	PutPixel(x+2,y,1,0);
	PutPixel(x  ,y+1,1,0);
	PutPixel(x+1,y+1,1,0);
	PutPixel(x+1,y+2,1,0);
}
开发者ID:Aliandrana,项目名称:uzebox,代码行数:8,代码来源:gameoflife.c

示例5: Line

static void Line(int x1,int y1,int x2,int y2,int ucPixel) /* ucPixel == color */
 {
    int *px,*py,y,a,b,a1,b1,a2,b2,Aincr,
	Bincr,bincr,d,dx,dy,da,db;

    if(x2==x1)  /* Algorytm Bresenhama */
    {
      if(y1>y2) nSwap(&y1,&y2);
      for(y=y1; y<=y2; y++)
	PutPixel(x1,y,ucPixel);
      return;
    }

    dy=y2-y1;
    dx=x2-x1;

    if(ABS(dy)<=ABS(dx))
    {
      b2=y2; b1=y1; a2=x2; a1=x1;
      px=&a; py=&b;
    }
    else
    {
      b2=x2; b1=x1; a2=y2; a1=y1;
      px=&b; py=&a;
    }

    if(a1>a2)
    {
      nSwap(&a1,&a2);
      nSwap(&b1,&b2);
    }

    if(b2>b1)
      bincr=1;
    else
      bincr=-1;

    da=a2-a1; db=ABS(b2-b1);
    d=2*db-da;
    Aincr=2*(db-da);
    Bincr=2*db;

    a=a1; b=b1;
    PutPixel(*px,*py,ucPixel);

    for(a=a1+1; a<=a2; a++)
    {
      if(d>=0)
      {
	b+=bincr;
	d+=Aincr;
      }
      else d+=Bincr;
      PutPixel(*px,*py,ucPixel );
    }
 }
开发者ID:dellagustin,项目名称:mp31,代码行数:57,代码来源:wig2gif.c

示例6: GetShape

void Cursor::Show (void) {
  if (x-1>=0 || y-1>=0 || x-1+sizex<320 || y-1+sizey<200)
    GetShape (x-1,y-1,sizex,sizey,buffer);
  PutPixel (x,y+1,15);
  PutPixel (x,y-1,15);
  PutPixel (x+1,y,15);
  PutPixel (x-1,y,15);
  visible=1;
}
开发者ID:TimofonicJunkRoom,项目名称:Oldies,代码行数:9,代码来源:cursor.cpp

示例7: Display_DrawLine_If

inline void Display_DrawLine_If(uint32_t xs, uint32_t xe, uint32_t ys, uint32_t ye, uint16_t colour)
{
	/* Bresenham Algorithm */
	int  wwx,hhy,x,y,n,sx,sy,e;
	uint16_t dx,dy;

	wwx = (int)(xe - xs);
	hhy = (int)(ye - ys);
	dx  = ABS(wwx);
	dy  = ABS(hhy);

	if (wwx > 0) sx = 1; else sx = -1;
	if (hhy > 0) sy = 1; else sy = -1;

	x = xs;
	y = ys;

	if ( dx >= dy )
	{
		e = dx;

		for(n=0; n<=dx; ++n){

			PutPixel(x,y,colour);
			x += sx;
			e += 2*dy;

			if (e >= 2*dx){
				e -= 2*dx;
				y += sy;
			}
		}

	}
	else
	{
		e = dy;

		for(n=0; n<=dy; ++n){

			PutPixel(x,y,colour);
			y += sy;
			e += 2*dx;

			if (e>=2*dy){
				e -= 2*dy;
				x += sx;
			}
		}
	}

}
开发者ID:PascalSI,项目名称:STM32Primer2_GPS_Tracker,代码行数:52,代码来源:display_if_support.c

示例8: R_ASSERT

void CImage::Hflip()
{
	R_ASSERT(pData);
	for (u32 y=0; y<dwHeight; y++)
	{
		for (u32 x=0; x<dwWidth/2; x++) {
			u32 x2 = dwWidth-x-1;
			u32 t = GetPixel(x,y);
			PutPixel(x,y, GetPixel(x2,y));
			PutPixel(x2,y,t);
		}
	}
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:13,代码来源:Image.cpp

示例9: abs

void CRenderer::Line(Vector p1, Vector p2, int color) {
	int dx, dy, de, err, i, x, y, t;
	int *scr = (int *)screen->pixels;
	int pitch = screen->pitch / 4;

	if(abs(p2.x - p1.x) > abs(p2.y - p1.y)) {
		if(p1.x > p2.x) {
			t = p1.x; p1.x = p2.x; p2.x = t;
			t = p1.y; p1.y = p2.y; p2.y = t;
			}

		t = p2.x - p1.x;
		de = abs(p2.y - p1.y);
		err = t / 2;
		if(p2.y > p1.y) dy = 1;
		else dy = -1;

		y = p1.y;
		for(i = p1.x; i <= p2.x; i++) {
			PutPixel(i,y,color);
			//scr[i + y * pitch] = color;
			err -= de;
			if(err < 0) {
				y += dy;
				err += t;
				}
			}
	} else {
		if(p1.y > p2.y) {
			t = p1.x; p1.x = p2.x; p2.x = t;
			t = p1.y; p1.y = p2.y; p2.y = t;
			}

		t = p2.y - p1.y;
		de = abs(p2.x - p1.x);
		err = t / 2;
		if(p2.x > p1.x) dx = 1;
		else dx = -1;

		x = p1.x;
		for(i = p1.y; i <= p2.y; i++) {
			PutPixel(x,i,color);
			//scr[x + i * pitch] = color;
			err -= de;
			if(err < 0) {
				x += dx;
				err += t;
				}
			}
		}
}
开发者ID:lemmit,项目名称:DugOff,代码行数:51,代码来源:Renderer.cpp

示例10: Display_FillCircle_If

inline void Display_FillCircle_If(uint16_t x_ct,uint16_t y_ct,long diameter, uint16_t colour)
{
	/* Bresenham Midpoint Algorithm */
	long cx, cy, d, dH, dD, n;
	long radius= diameter/2;
	
    d   = 1 - radius;
    dH  = 3;
    dD  = 5 - 2 * radius;
    cy  = radius;

    for (cx = 0; cx <= cy; cx++) {
        if (d < 0) {
            d   += dH;
            dH  += 2;
            dD  += 2;
        }
        else{
            d   += dD;
            dH  += 2;
            dD  += 4;
            --cy;
        }

		/* Between 0-45deg */
		n = 2*cy;
		do{
			PutPixel((cy-n)+ x_ct,cx + y_ct,colour);
		} while (n--);

		/* Between 45-90deg */
		n = 2*cx;
		do{
			PutPixel((cx-n)+ x_ct,cy + y_ct,colour);
		} while (n--);

		/* Between 270-315deg */
		n = 2*cx;
		do{
			PutPixel((cx-n)+ x_ct,-cy + y_ct,colour);
		} while (n--);

		/* Between 315-360deg */
		n = 2*cy;
		do{
			PutPixel((cy-n)+ x_ct,-cx + y_ct,colour);
		} while (n--);

    }
}
开发者ID:PascalSI,项目名称:STM32Primer2_GPS_Tracker,代码行数:50,代码来源:display_if_support.c

示例11: PutPixel

//the results of a take away equation becomes the blue drawn pixels 
void Pixel_Manager::TakeAwayResult_Drawn(int arg_one , int arg_two, int result_value, int color_value, SDL_Surface *Surface, int square_x_size, int square_y_size) {
		for(int x = 0; x<= square_x_size; x++){
				for(int y = 0; y<= square_y_size; y++) {
					result_value = arg_two - arg_one;
					if(result_value  <= y*x) {
						color_value=0xff0000;
						PutPixel(x,y, color_value, Surface); //std::cout << "red" << std::endl;
					} else {
						color_value=0x0000ff;
						PutPixel(x,y, color_value, Surface); //std::cout << "Blue" << std::endl;	
				    }		
				}
			}
		}
开发者ID:xXxRosexXxEE,项目名称:Pixel-Manager,代码行数:15,代码来源:main.cpp

示例12: main

int main(){

	unsigned int i;
	unsigned int j;

	ClearVram();
	SetBorderColor(0xBFU);

	/* Fill VRAM */

	for (i = 0U; i < VRAM_SIZE; i++){
		aram[i * 2U     ] = (i     ) & 0xFFU;
		aram[i * 2U + 1U] = (i * 3U) & 0xFFU;
	}

	for (i = 0U; i < VRAM_SIZE; i++){
		vram[i] = (i * 5U) & 0xFFU;
	}

	/* Bitmap modes */

	palette[0] = 0x00U;
	palette[1] = 0xC0U;
	palette[2] = 0x38U;
	palette[3] = 0xF8U;
	palette[4] = 0x07U;
	palette[5] = 0xC7U;
	palette[6] = 0x3FU;
	palette[7] = 0xFFU;

	SetTileTableRow(M40_TILEROW_3BPP, 8U);
	SetTileTableRow(M40_TILEROW_3BPP, 9U);
	SetTileTableRow(M40_TILEROW_3BPP, 10U);
	SetTileTableRow(M40_TILEROW_3BPP, 11U);

	SetTileTableRow(M40_TILEROW_1BPP, 12U);
	SetTileTableRow(M40_TILEROW_1BPP, 13U);
	SetTileTableRow(M40_TILEROW_1BPP, 14U);
	SetTileTableRow(M40_TILEROW_1BPP, 15U);

	for (j = 0U; j < 16U; j ++){
		for (i = 0U; i < 32U; i ++){
			PutPixel(i + (j << 1) + 0U, i + 32U, j);
			PutPixel(i + (j << 1) + 1U, i + 32U, j);
		}
	}

	while(1);

}
开发者ID:lawrencebrooks,项目名称:uzebox,代码行数:50,代码来源:main.c

示例13: Display_DrawCircle_If

inline void Display_DrawCircle_If(uint16_t x_ct,uint16_t y_ct,long diameter, uint16_t colour)
{
	/* Bresenham Midpoint Algorithm */
   long cx, cy, d, dH, dD;

    d   = 1 - radius;
    dH  = 3;
    dD  = 5 - 2 * radius;
    cy  = radius;

    for (cx = 0; cx <= cy; cx++) {
        if (d < 0) {
            d   += dH;
            dH  += 2;
            dD  += 2;
        }
        else{
            d   += dD;
            dH  += 2;
            dD  += 4;
            --cy;
        }

        PutPixel( cy + x_ct,  cx + y_ct, colour);	/* Between   0- 45 */
        PutPixel( cx + x_ct,  cy + y_ct, colour);	/* Between  45- 90 */
        PutPixel(-cx + x_ct,  cy + y_ct, colour);	/* Between  90-135 */
        PutPixel(-cy + x_ct,  cx + y_ct, colour);	/* Between 135-180 */
        PutPixel(-cy + x_ct, -cx + y_ct, colour);	/* Between 180-225 */
        PutPixel(-cx + x_ct, -cy + y_ct, colour);	/* Between 225-270 */
        PutPixel( cx + x_ct, -cy + y_ct, colour);	/* Between 270-315 */
        PutPixel( cy + x_ct, -cx + y_ct, colour);	/* Between 315-360 */
    }
}
开发者ID:PascalSI,项目名称:STM32Primer2_GPS_Tracker,代码行数:33,代码来源:display_if_support.c

示例14: lwss

void lwss(u8 x,u8 y){
	PutPixel(x+1,y,1,0);
	PutPixel(x+4,y,1,0);
	PutPixel(x,y+1,1,0);
	PutPixel(x,y+2,1,0);
	PutPixel(x+4,y+2,1,0);
	PutPixel(x,y+3,1,0);
	PutPixel(x+1,y+3,1,0);
	PutPixel(x+2,y+3,1,0);
	PutPixel(x+3,y+3,1,0);
}
开发者ID:Aliandrana,项目名称:uzebox,代码行数:11,代码来源:gameoflife.c

示例15: PutPixel

void D3DGraphics::DrawLine( int x1,int y1,int x2,int y2,D3DCOLOR c )
{	
	const int dx = x2 - x1;
	const int dy = y2 - y1;

	if( dy == 0 && dx == 0 )
	{
		PutPixel( x1,y1,c );
	}
	else if( abs( dy ) > abs( dx ) )
	{
		if( dy < 0 )
        {
            x1 += x2;
            x2 = x1 - x2;
            x1 -= x2;
            y1 += y2;
            y2 = y1 - y2;
            y1 -= y2;
		}
		const float m = (float)dx / (float)dy;
		const float b = x1 - m*y1;
		for( int y = y1; y <= y2; y = y + 1 )
		{
			int x = (int)(m*y + b + 0.5f);
			PutPixel( x,y,c );
		}
	}
	else
	{
		if( dx < 0 )
        {
            x1 += x2;
            x2 = x1 - x2;
            x1 -= x2;
            y1 += y2;
            y2 = y1 - y2;
            y1 -= y2;
		}
		const float m = (float)dy / (float)dx;
		const float b = y1 - m*x1;
		for( int x = x1; x <= x2; x = x + 1 )
		{
			int y = (int)(m*x + b + 0.5f);
			PutPixel( x,y,c );
		}
	}
}
开发者ID:DanielAckerson,项目名称:GameOfLife,代码行数:48,代码来源:D3DGraphics.cpp


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