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

C++ setpixel函数代码示例

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

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



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

示例1: main

int main(int argc, char *argv[]) {
    int i=0;
    int x=40,y=20;
    srandom(time(NULL));
    while(1) {
        if (i==0) {
            x=rand()%XSIZE;
            y=rand()%YSIZE;
            clearscreen();
        }
        printf("fljsdf\n");
        i=(i+1)%1000;

            x=XSIZE+(x-1+rand()%2) % XSIZE;
            y=YSIZE+(y-1+rand()%2) % YSIZE;
            setpixel(x,y);
            setpixel(x+1,y);
            setpixel(x+1,y+1);
            setpixel(x,y+1);
        
        writescreen();
        usleep(15000);
    }
    return 0;
}
开发者ID:entropia,项目名称:lcd,代码行数:25,代码来源:plane.c


示例2: draw_preview_block

void draw_preview_block(char x, char y) {
	byte x_start, y_start, x1, y1;
	byte i;

	x_start = PREVIEW_X + BLOCK_SIZE * x;
	y_start = PREVIEW_Y + BLOCK_SIZE * y;

	x1 = x_start;
	y1 = y_start + BLOCK_SIZE - 1;
	for (i = 0; i < BLOCK_SIZE; i++) {
		setpixel(x1, y_start);
		setpixel(x1, y1);
		x1++;
	}

	x1 = x_start + BLOCK_SIZE - 1;
	y1 = y_start + 1;
	for (i = 0; i < BLOCK_SIZE - 2; i++) {
		setpixel(x_start, y1);
		setpixel(x1, y1);
		y1++;
	}

	setpixel(x_start + 2, y_start + 2);
}
开发者ID:bogger33,项目名称:homebrewcomp,代码行数:25,代码来源:tmain.c


示例3: seg7_img_draw

void   seg7_img_draw  (struct seg7_img_t *img, int value)
{
  int i,j;
  int pixel;
 
  pixel = (img->x + img->y*machine.ui.width)*machine.ui.bpp;
  for(i=0; i < img->h; i++)
    {
      int pii = pixel;
      for(j=0; j < img->w; j++)
	{
	  if ((value & img->img[j][i]) != 0)
	    {
	      setpixel(pii,0xee,0x00,0x00); /* on */
	    }
	  else if (img->img[j][i] > 0)
	    {
	      setpixel(pii,0x30,0x30,0x30); /* off */
	    }
	  else
	    {
	      setpixel(pii,0x00,0x00,0x00); /* bkg */
	    }
	  pii += 3;
	}
      pixel += machine.ui.width * machine.ui.bpp;
    }
}
开发者ID:ESS-Group,项目名称:WSim,代码行数:28,代码来源:7seg_img.c


示例4: fillcircle

// draw a circle
void fillcircle(uint8_t *buff,
	      uint8_t x0, uint8_t y0, uint8_t r, 
	      uint8_t color) {
  int8_t f = 1 - r;
  int8_t ddF_x = 1;
  int8_t ddF_y = -2 * r;
  int8_t x = 0;
  int8_t y = r;

  for (uint8_t i=y0-r; i<=y0+r; i++) {
    setpixel(buff, x0, i, color);
  }

  while (x<y) {
    if (f >= 0) {
      y--;
      ddF_y += 2;
      f += ddF_y;
    }
    x++;
    ddF_x += 2;
    f += ddF_x;
  
    for (uint8_t i=y0-y; i<=y0+y; i++) {
      setpixel(buff, x0+x, i, color);
      setpixel(buff, x0-x, i, color);
    } 
    for (uint8_t i=y0-x; i<=y0+x; i++) {
      setpixel(buff, x0+y, i, color);
      setpixel(buff, x0-y, i, color);
    }    
  }
}
开发者ID:Tyler-Ward,项目名称:EMECS_clock,代码行数:34,代码来源:glcd.c


示例5: write_text_to_buffer

void write_text_to_buffer(char* textbuffer) {
	for(int i = 0; i < COLUMNS; i++) {  // CLEAR FRAME FIRST
		for(int x = 0; x < ROWS; x++) {
			setpixel(i, x, bckred, bckgreen, bckblue);
		}
	}

	for(int i = 0; i < COLUMNS; i++) {
			for(int x = 0; x < ROWS; x++) {
				if(i < TEXTWIDTH) {
					bool pix = font8x8_basic[textbuffer[0]][x] & (1 << (i));
					if(pix) {
						setpixel(i, x, txtred, txtgreen, txtblue);
					} else {
						setpixel(i, x, bckred, bckgreen, bckblue);
					}

					int columnplace = i + TEXTWIDTH + TEXTOFFSET;

					pix = font8x8_basic[textbuffer[1]][x] & (1 << (i));
					if(pix) {
						setpixel(columnplace, x, txtred, txtgreen, txtblue);
					} else {
						setpixel(columnplace, x, bckred, bckgreen, bckblue);
					}
				}
			}
	}
}
开发者ID:houzhenggang,项目名称:ESP8266-3,代码行数:29,代码来源:main.cpp


示例6: overlay_one_inplace

static void overlay_one_inplace(
		float *ox, float *oy, float *of, // background images and flow
		int w, int h, int pd,            // dimensions of background
		float *ppx, int pw, int ph,      // overlaid image and its size
		float posx, float posy,          // overlay position
		float zoom, float angle,         // overlay transformation
		float dx, float dy               // overlay displacement
		)
{
	float (*px)[pw][pd] = (void*)ppx;
	float dxy[2] = {dx, dy};
	float sina = sin(angle*M_PI/180.0);
	float cosa = cos(angle*M_PI/180.0);
	for (int j = 0; j < ph; j++)
	for (int i = 0; i < pw; i++)
	{
		float cij[2] = {i - pw/2.0, j - ph/2.0};
		float ai = pw/2.0 + zoom * ( cosa * cij[0] + sina * cij[1]);
		float aj = ph/2.0 + zoom * (-sina * cij[0] + cosa * cij[1]);
		ai = round(ai);
		aj = round(aj);
		float adxy[2] = {dx + ai - i, dy + aj - j};
		// TODO: correct re-sampling (!)

		setpixel(ox,w,h,pd, posx + i      , posy + j      , px[j][i]);
		setpixel(oy,w,h,pd, posx + dx + ai, posy + dy + aj, px[j][i]);
		setpixel(of,w,h,2 , posx + i      , posy + j      , adxy);
	}
}
开发者ID:Fahdben,项目名称:imscript,代码行数:29,代码来源:overflow.c


示例7: filter_threshold

void filter_threshold(struct image *img, int threshold)
{
    struct image *dst;
    int x, y;
    int r, g, b;
    int min = 0, max = 255;

    dst = image_new(img->width, img->height);

    if(threshold < 0)
    {
        min = 255;
        max = 0;
        threshold = -threshold;
    }

    threshold *= 3;

    for(y = 0; y < img->height; y++)
        for(x = 0; x < img->width; x++)
        {
            getpixel(img, x, y, &r, &g, &b);
            if(r + g + b < threshold)
                setpixel(dst, x, y, min, min, min);
            else
                setpixel(dst, x, y, max, max, max);
        }

    image_swap(img, dst);
    image_free(dst);
}
开发者ID:hex2tan,项目名称:pwntcha,代码行数:31,代码来源:filter.c


示例8: ez430_lcd_img_draw

void ez430_lcd_img_draw(struct ez430_lcd_img_t *img, uint8_t mem[15], uint8_t bmem[15])
{
  int i, j, k;
  int pixel;

  pixel = (img->x + img->y * machine.ui.width) * machine.ui.bpp;
  for (i = 0; i < img->h; i++) {
    int pii = pixel;
    for (j = 0; j < img->w; j++) {
      setpixel(pii, 0x00, 0x00, 0x00); // bkg
      for (k = 0; k < 12; k++) {
        if ((mem[k] & img->img[j][i][k]) != 0) {
          if ((bmem[k] & img->img[j][i][k]) != 0) {
            setpixel(pii, 0x00, 0xee, 0x00); // blink
            break;
          } else {
            setpixel(pii, 0xee, 0x00, 0x00); // on
            break;
          }
        } else if (img->img[j][i][k] > 0) {
          setpixel(pii, 0x30, 0x30, 0x30); // off
        }
      }
      pii += 3;
    }
    pixel += machine.ui.width * machine.ui.bpp;
  }
}
开发者ID:afrab,项目名称:WSim,代码行数:28,代码来源:ez430_lcd_img.c


示例9: linebres

void linebres(int xa, int ya, int xb, int yb)
{
	int dx = abs(xa-xb), dy = abs(ya-yb);
	int p= 2*dy-dx;
	int twody = 2*dy, twodydx = 2*(dy-dx);
	int x,y,xEnd;

	if(xa>xb)
	{
		x=xb;
		y=yb;
		xEnd = xa;
	}

	else{
		x=xa;
		y=ya;
		xEnd =xb;
	}

	setpixel (x,y);
	while(x<xEnd){
		x++;
		if(p<0)
			p+=twody;
		else{
			y++;
			p+=twodydx;
		}
		setpixel(x,y);
	}
}
开发者ID:raj-maurya,项目名称:Competitive-Programming,代码行数:32,代码来源:brensenhams_line.c


示例10: drawrect

// draw a rectangle
void drawrect(unsigned char *buff, unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned char color) {
  // stupidest version - just pixels - but fast with internal buffer!
  for (uint8_t i=x; i<x+w; i++) {
    setpixel(buff, i, y, color);
    setpixel(buff, i, y+h-1, color);
  }
  for (uint8_t i=y; i<y+h; i++) {
    setpixel(buff, x, i, color);
    setpixel(buff, x+w-1, i, color);
  } 
}
开发者ID:MattDurr,项目名称:HomeAutomationLabs,代码行数:12,代码来源:stlcd.c


示例11: setpixel

// draw a rectangle
void SSD1306::drawrect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, 
		      uint8_t color) {
  // stupidest version - just pixels - but fast with internal buffer!
  for (uint8_t i=x; i<x+w; i++) {
    setpixel(i, y, color);
    setpixel(i, y+h-1, color);
  }
  for (uint8_t i=y; i<y+h; i++) {
    setpixel(x, i, color);
    setpixel(x+w-1, i, color);
  } 
}
开发者ID:Rhapsody950521,项目名称:GoKit-Arduino-MCU,代码行数:13,代码来源:SSD1306.cpp


示例12: write_texttowall

void ICACHE_FLASH_ATTR write_texttowall(int buffer, int textbuffer, long offset, int fR, int fG, int fB, int fbR, int fbG, int fbB) {
	 for(int i = 0; i < COLUMNS; i++) {
		for(int x = 0; x < ROWS; x++) {
			char pix = get_textpixel(textbuffer, i, x, offset);
			if(pix > 0) {
				setpixel(buffer, i, x,  fR, fG, fB);
			} else {
				setpixel(buffer, i, x,  fbR, fbG, fbB);
			}
		}
	 }
}
开发者ID:houzhenggang,项目名称:ESP8266-3,代码行数:12,代码来源:framedriver.c


示例13: filter_fill_holes

void filter_fill_holes(struct image *img)
{
    struct image *dst;
    int x, y;
    int r, g, b;

    dst = image_new(img->width, img->height);

    for(y = 0; y < img->height; y++)
        for(x = 0; x < img->width; x++)
        {
            getpixel(img, x, y, &r, &g, &b);
            setpixel(dst, x, y, r, g, b);
        }

    for(y = 0; y < dst->height; y++)
        for(x = 2; x < dst->width - 2; x++)
        {
            int c1, c2, c3, c4, c5;
            getpixel(img, x-2, y, &c1, &g, &b);
            getpixel(img, x-1, y, &c2, &g, &b);
            getpixel(img, x, y, &c3, &g, &b);
            getpixel(img, x+1, y, &c4, &g, &b);
            getpixel(img, x+2, y, &c5, &g, &b);
            if(c1 < 127 && c2 < 127 && c3 > 128 && c4 < 127)
                c3 = (c1 + c2 + c4) / 3;
            else if(c2 < 127 && c3 > 128 && c4 < 127 && c5 < 127)
                c3 = (c2 + c4 + c5) / 3;
            setpixel(dst, x, y, c3, c3, c3);
        }

    for(x = 0; x < dst->width; x++)
        for(y = 2; y < dst->height - 2; y++)
        {
            int c1, c2, c3, c4, c5;
            getpixel(img, x, y-2, &c1, &g, &b);
            getpixel(img, x, y-1, &c2, &g, &b);
            getpixel(img, x, y, &c3, &g, &b);
            getpixel(img, x, y+1, &c4, &g, &b);
            getpixel(img, x, y+2, &c5, &g, &b);
            if(c1 < 127 && c2 < 127 && c3 > 128 && c4 < 127)
                c3 = (c1 + c2 + c4) / 3;
            else if(c2 < 127 && c3 > 128 && c4 < 127 && c5 < 127)
                c3 = (c2 + c4 + c5) / 3;
            setpixel(dst, x, y, c3, c3, c3);
        }

    image_swap(img, dst);
    image_free(dst);
}
开发者ID:hex2tan,项目名称:pwntcha,代码行数:50,代码来源:filter.c


示例14: drawline

// Bresenham's algorithm - From wikipedia
void drawline(uint8_t *buff, uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t color) 
{
	uint8_t steep = abs(y1 - y0) > abs(x1 - x0);
	if (steep) 
	{
		swap(x0, y0);
		swap(x1, y1);
	}

	if (x0 > x1) 
	{
		swap(x0, x1);
		swap(y0, y1);
	}

	uint8_t dx, dy;
	dx = x1 - x0;
	dy = abs(y1 - y0);

	int8_t err = dx / 2;
	int8_t ystep;

	if (y0 < y1) 
	{
		ystep = 1;
	} 
	else 
	{
		ystep = -1;
	}

	for (; x0<x1; x0++) 
	{
		if (steep) 
		{
			setpixel(buff, y0, x0, color);
		} 
		else 
		{
			setpixel(buff, x0, y0, color);
		}
		err -= dy;
		if (err < 0) 
		{
			y0 += ystep;
			err += dx;
		}
	}
}
开发者ID:david-furminieux,项目名称:nextcopterplus,代码行数:50,代码来源:glcd_driver.c


示例15: render

void render(){
    int i, j;
    int color[3];
    int pos[2];

    for(i = 0; i < lastBlock; i++){
        color[0] = blockList[i].program[0] / 8.0 * 255;
        color[1] = blockList[i].program[INSTRUCTIONS / 2] / 8.0 * 255;
        color[2] = blockList[i].program[INSTRUCTIONS - 1] / 8.0 * 255;
        if(blockList[i].die){
            if(blockList[i].energy < 1){
                color[0] = color[0] - 70 < 0?0:color[0] - 70;
                color[1] = color[1] - 70 < 0?0:color[1] - 70;
                color[2] = color[2] - 70 < 0?0:color[2] - 70;
            }else{
                color[0] = color[0] - 90 < 0?0:color[0] - 70;
                color[1] = color[1] - 90 < 0?0:color[1] - 70;
                color[2] = color[2] - 90 < 0?0:color[2] - 70;
            }
        }
        pos[0] = blockList[i].x;
        pos[1] = blockList[i].y; 
        setpixel(pos[0], pos[1], color[0], color[1], color[2]);
    }
    SDL_Flip(screen);
    SDL_FillRect(screen, NULL, 0x000000);
}
开发者ID:MateusZitelli,项目名称:Tree-Bots,代码行数:27,代码来源:lt.c


示例16: filter_flood_fill

/* Functions */
void filter_flood_fill(struct image *img, int x, int y, int r, int g, int b)
{
    int oldr, oldg, oldb;
    int nextr, nextg, nextb;

    if(x < 0 || y < 0 || x >= img->width || y >= img->height)
        return;

    getpixel(img, x, y, &oldr, &oldg, &oldb);
    setpixel(img, x, y, r, g, b);

    getpixel(img, x + 1, y, &nextr, &nextg, &nextb);
    if(nextr == oldr && nextg == oldg && nextb == oldb)
        filter_flood_fill(img, x + 1, y, r, g, b);

    getpixel(img, x - 1, y, &nextr, &nextg, &nextb);
    if(nextr == oldr && nextg == oldg && nextb == oldb)
        filter_flood_fill(img, x - 1, y, r, g, b);

    getpixel(img, x, y + 1, &nextr, &nextg, &nextb);
    if(nextr == oldr && nextg == oldg && nextb == oldb)
        filter_flood_fill(img, x, y + 1, r, g, b);

    getpixel(img, x, y - 1, &nextr, &nextg, &nextb);
    if(nextr == oldr && nextg == oldg && nextb == oldb)
        filter_flood_fill(img, x, y - 1, r, g, b);
}
开发者ID:hex2tan,项目名称:pwntcha,代码行数:28,代码来源:filter.c


示例17: floodFill

void floodFill(int x, int y,struct fill fillColor,struct fill old)
{
    struct fill tmp;
    tmp=getpixcol(x,y);
    printf("r:%f g:%f b:%f\n",tmp.r,tmp.g,tmp.b);
    if(tmp.r * 1000!=old.r * 1000 || tmp.g*1000!=old.g*1000 || tmp.b*1000!=old.b*1000) {
        puts("RETURN");
        return;
    }
    setpixel(fillColor,x,y);
    int dx[4]= {1,0,-1};
    int dy[4]= {-1,0,1};
    for(int i=0; i<3; i++) {
        for(int j=0; j<3; j++) {
            //mrnd=(mrnd*7)%8;
            //int ind = mrnd>>1;
            //mrnd=ind;
            if(i==1 && j==1) continue;
            floodFill(x+dx[i],y+dy[j],fillC,old);
        }
    }

    glFlush();
    Sleep(2);
}
开发者ID:sriankit,项目名称:CGraphix,代码行数:25,代码来源:main.cpp


示例18: menu_setpixel

static void menu_setpixel(uint8_t x, uint8_t y, uint8_t isSet)
{
	uint8_t nColor;

	// mirror mirror on the wall, what's the quirkiest API of them all...
	x = NUM_COLS - 1 - x;
	uint8_t nMiddle = (NUM_COLS - MENU_WIDTH_ICON) / 2;

	if (isSet != 0)
	{
		if ((x >= nMiddle - MENU_WIDTH_DELIMITER) && (x < (nMiddle
		        + MENU_WIDTH_ICON + MENU_WIDTH_DELIMITER)))
		{
			nColor = 3;
		}
		else if ((x == (nMiddle - MENU_WIDTH_DELIMITER - 1)) || (x == (nMiddle
		        + MENU_WIDTH_ICON + MENU_WIDTH_DELIMITER)))
		{
			nColor = 2;
		}
		else
		{
			nColor = 1;
		}
	}
	else
	{
		nColor = 0;
	}

	setpixel((pixel){x, y}, nColor);
}
开发者ID:das-labor,项目名称:borgware-2d,代码行数:32,代码来源:menu.c


示例19: clear_buffer

void ICACHE_FLASH_ATTR clear_buffer(int buffer) {
	for(int i = 0; i < COLUMNS; i++) {
		for(int x = 0; x < ROWS; x++) {
			setpixel(buffer, i, x, 0x00, 0x00, 0x00);
		}
	}
}
开发者ID:houzhenggang,项目名称:ESP8266-3,代码行数:7,代码来源:framedriver.c


示例20: draw_single_field

/* this is the actual draw function for a single field
 */
static void draw_single_field (uint8_t in_x, uint8_t in_y, game_field_t in_f)
{
	pixel tmp;
	uint8_t b;
	switch (in_f)
	{
		case b1:
			b = 1;
		break;

		case rb:
		case b2:
			b = 2;
		break;

		case b3:
		case bl:
		case bs:
			b = 3;
		break;

		default: /* this includes freespace */
			b = 0;
		break;

	}
	tmp.x = in_x;
	tmp.y = in_y;
	setpixel (tmp, b);
}
开发者ID:das-labor,项目名称:borgware-2d,代码行数:32,代码来源:playfield.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ setpos函数代码示例发布时间:2022-05-30
下一篇:
C++ setpgrp函数代码示例发布时间: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