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


C++ setPixel函数代码示例

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


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

示例1: glGenTextures

// Constructs a sprite with some size. Useful for shaders
Sprite::Sprite(int sizeX, int sizeY)
{
    w = sizeX;
    h = sizeY;
    x = 0;
    y = 0;
    scale = 1.0;
    id = 0;
    glGenTextures(1, &id);
    assert(id);
    opacity = 1.0f;
    name = tbox.resolutionToString(w, h);
    
    glBindTexture(GL_TEXTURE_2D, id);
    
    GLuint target = GL_TEXTURE_2D;
    spriteSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, 0, 0, 0, 0);
    
    // Get the texture format. We will want to create it according to the SDL surface
    format = checkGeneric(spriteSurface);
    
    // Lock the surface for direct pixel acccess
    SDL_LockSurface(spriteSurface);
    
    SDL_Color color;
    
    // Init the surface with random colors. Useful for debugging
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            color = tbox.getRandomColor();
            setPixel(spriteSurface, i, j, color);
        }
    }
    
    // Done, unlock
    SDL_UnlockSurface(spriteSurface);
    
    // Create the actual OpenGL texture
    glTexImage2D(target,
        0,
        format,
        spriteSurface->w,
        spriteSurface->h,
        0,
        format,
        GL_UNSIGNED_BYTE,
        spriteSurface->pixels);

    glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    fprintf(stderr, "New sprite built with following properties: Generic sprite %s\n", name.c_str());
}
开发者ID:jsj2008,项目名称:Captain,代码行数:53,代码来源:sprite.cpp

示例2: clearBit

void ILI9325i2c_16::rotateChar(byte c, int x, int y, int pos, int deg)
{
  byte i, j, ch;
  word temp;
  int newx, newy;
  double radian;
  radian = deg * 0.0175;

  clearBit(CS);

  temp = ((c - cfont.offset) * ((cfont.x_size / 8) * cfont.y_size)) + 4;
  for (j = 0; j < cfont.y_size; j++)
  {
    for (int zz = 0; zz < (cfont.x_size / 8); zz++)
    {
      ch = pgm_read_byte(&cfont.font[temp + zz]);
      for (i = 0; i < 8; i++)
      {
        newx = x + (((i + (zz * 8) + (pos * cfont.x_size)) * cos(radian)) - ((j) * sin(radian)));
        newy = y + (((j) * cos(radian)) + ((i + (zz * 8) + (pos * cfont.x_size)) * sin(radian)));

        setXY(newx, newy, newx + 1, newy + 1);

        if ((ch & (1 << (7 - i))) != 0)
        {
          setPixel(fcolorr, fcolorg, fcolorb);
        }
        else
        {
          setPixel(bcolorr, bcolorg, bcolorb);
        }
      }
    }
    temp += (cfont.x_size / 8);
  }

  setBit(CS);
  clrXY();
}
开发者ID:PhillyNJ,项目名称:ILI9325i2c_16,代码行数:39,代码来源:ILI9325i2c_16.cpp

示例3: autoDropped

// ----------------------------------------------------------------------------
ITexture* Terrain::createSplattingImg()
{
    IVideoDriver* vd = Editor::getEditor()->getVideoDriver();

    auto img = autoDropped(
        vd->createImage(ECF_A8R8G8B8, dimension2du(SPIMG_X, SPIMG_Y)));

    for (u32 i = 0; i < SPIMG_X; i++)
        for (u32 j = 0; j < SPIMG_Y; j++)
            img->setPixel(i, j, SColor(255, 0, 0, 0));

    return vd->addTexture("splatt.png", img.get());
} // initSplattingImg
开发者ID:Boyquotes,项目名称:stk-editor,代码行数:14,代码来源:terrain.cpp

示例4: getPixelIdx

// drawPixel sets or clears a certain pixel depending on whether the colour
// is greater than 0 or not
void PixelStates::drawPixel(int16_t x, int16_t y, uint16_t color) {
	uint16_t pixelIdx = getPixelIdx(x, y);

	if(pixelIdx < 0) {
		return;
	}

	if(color > 0) {
		setPixel(pixelIdx);
	} else {
		clearPixel(pixelIdx);
	}
}
开发者ID:thecolonel999,项目名称:Word-Clock,代码行数:15,代码来源:PixelStates.cpp

示例5: DDADraw

bool DDADraw(int x0, int y0, int xEnd, int yEnd, int width, int height, float* PixelBuffer, float red, float green, float blue)
{
    int dx = xEnd - x0, dy = yEnd - y0, steps, k;
    float xIncrement, yIncrement, x = x0, y = y0;
    if (x0 < 0 || y0 < 0 || xEnd > width || yEnd > height)
        return false;

    if (fabs(dx) > fabs(dy))
        steps = fabs(dx);
    else
        steps = fabs(dy);
    xIncrement = float(dx) / float(steps);
    yIncrement = float(dy) / float(steps);

    setPixel(PixelBuffer, round(x), round(y), width, height, red, blue, green);
    for (k = 0; k < steps; k++) {
        x += xIncrement;
        y += yIncrement;
        setPixel(PixelBuffer, round(x), round(y), width, height, red, blue, green);
    }
    return true;
}
开发者ID:jaseat,项目名称:ECS175project2,代码行数:22,代码来源:GraphicsProc.cpp

示例6: display

void display(void) {
  int i,j;
  glClear(GL_COLOR_BUFFER_BIT);

  for (i=20;i<100;i++) {
    for (j=0;j<100;j++) {
      setPixel(i, j, pow(sin((i+g_phase)/8.0f),2.0f), j/100.0f, 0.5f);
    }
  }

  glDrawPixels(100, 100, GL_RGB, GL_FLOAT, pixels);
  glutSwapBuffers();  // double buffering woo hoo!
}
开发者ID:emiraga,项目名称:1window1pixel,代码行数:13,代码来源:main.c

示例7: drawHollowRect

/**
Here we draw 4 seperate rectangles for the outline of a hollow rectangle.
We first draw the top row, then the leftmost coloumn. We then draw the 
bottom rectangle, and then the rightmost. 
**/
void drawHollowRect(int r, int c, int width, int height, u16 color) {
    int i;
    int j;

    // Here we draw the vertical lines
    for (i = r; i<(r+height) && 160; i++) {
        setPixel(i,c,color);
        j = c + width-1;
        if (j<=240) {
            setPixel(i, j, color);
        }
    }

    // Here we draw the horizontal lines
    for (j = c; j<(c+width) && 240; j++) {
        setPixel(r, j, color);
        i = r + height-1;
        if (i<=160) {
            setPixel(i , j, color);
        }
    }
}
开发者ID:jfoster39,项目名称:2110Homework8,代码行数:27,代码来源:mylib.c

示例8: mirror

/**
 * Mirrors an image either horizontally, vertically, or both.
 */
void mirror(int directions, struct IMAGE* image) {
    int x;
    int y;

    const bool horizontal = !!((directions & 1<<HORIZONTAL) != 0);
    const bool vertical = !!((directions & 1<<VERTICAL) != 0);
    int untilX = ((horizontal==true)&&(vertical==false)) ? ((image->width - 1) >> 1) : (image->width - 1);  // w>>1 == (int)(w-0.5)/2
    int untilY = (vertical==true) ? ((image->height - 1) >> 1) : image->height - 1;

    for (y = 0; y <= untilY; y++) {
        const int yy = (vertical==true) ? (image->height - y - 1) : y;
        if ((vertical==true) && (horizontal==true) && (y == yy)) { // last middle line in odd-lined image mirrored both h and v
            untilX = ((image->width - 1) >> 1);
        }
        for (x = 0; x <= untilX; x++) {
            const int xx = (horizontal==true) ? (image->width - x - 1) : x;
            const int pixel1 = getPixel(x, y, image);
            const int pixel2 = getPixel(xx, yy, image);
            setPixel(pixel2, x, y, image);
            setPixel(pixel1, xx, yy, image);
        }
    }
开发者ID:astok,项目名称:unpaper,代码行数:25,代码来源:imageprocess.c

示例9: DDALine

//Taken from Computer Graphics with GL. Unused
void DDALine(int startX, int startY, int endX, int endY) {
	int dx = endX - startX;
	int dy = endY - startY;
	int steps, k;

	float xInc, yInc, x = startX, y = startY;

	if (fabs(dx) > fabs(dy))
		steps = fabs(dx);
	else
		steps = fabs(dy);

	xInc = float(dx) / float(steps);
	yInc = float(dy) / float(steps);

	setPixel(round(x), round(y));
	for (k = 0; k < steps; k++) {
		x += xInc;
		y += yInc;
		setPixel(round(x), round(y));
	}
}
开发者ID:Derongan,项目名称:ecs175HW1,代码行数:23,代码来源:Source.cpp

示例10: pintaImagem

void  pintaImagem(Imagem *img, float cor)
	/*	A função recebe como parâmetro o endereço de uma imagem e colo-
		ca em todos os pixels dela uma cor (representado por um número 
		float), */
{
	int i,j;
	
	for(i = 0; i < img->nL; i++) {
		for(j = 0; j < img->nC; j++) {
			setPixel(img, i, j, cor);
		}
	}
}
开发者ID:renatocf,项目名称:MAC0122,代码行数:13,代码来源:mondrian_com_print.c

示例11: printCode

void printCode(uint16_t c)
{
  uint8_t n,k,temp;
  cls();
  for(k=0;k<3;k++)
  {
    temp=0;
    for(n=0;n<NUMROWS;n++)
    {
      if((smallbitmap[c][n]<<k)&0x80)setPixel(k+SHIFTLEFT,NUMROWS-1-n,1);
    }
  }
}
开发者ID:ChrisMicro,项目名称:CH2_Computer,代码行数:13,代码来源:display.c

示例12: drawRect

/**
Cycles through two for loops and set a pixel for each iteration
**/
void drawRect(int r, int c, int width, int height, u16 color) {
	int i;
	int j;
	int cReset = c;
	for (i = 0; i < width; i++) {
		for (j = 0; j < height; j++) {
			setPixel(r, c ,color);
			c++;
		}
	c = cReset;
	r++;
	}
}
开发者ID:jfoster39,项目名称:2110Homework8,代码行数:16,代码来源:mylib.c

示例13: setPixel

void Glowprobe::setColumn(uint8_t fb, uint8_t lr, uint8_t r, uint8_t g, uint8_t b) {
  setPixel(fb, lr, 0, r, g, b);
  setPixel(fb, lr, 1, r, g, b);
  setPixel(fb, lr, 2, r, g, b);
  setPixel(fb, lr, 3, r, g, b);
  setPixel(fb, lr, 4, r, g, b);
  setPixel(fb, lr, 5, r, g, b);
}
开发者ID:hamiltron,项目名称:glowprobe,代码行数:8,代码来源:Glowprobe.cpp

示例14: pintaRegiao

void pintaRegiao(CelPixel *cab, Imagem *R, Imagem *G, Imagem *B, 
		 float cor[3])
	/*	A função recebe uma lista encadeada de pixels que fazem parte
		de uma subregião, três imagens (canais) e um vetor com as cores-
		padrão. Para cada posição do pixel, colore cada cor corresponden-
		te nas imagens R, G e B. */
{
	int i, j;
	CelPixel *pixel_atual;
	pixel_atual = cab->prox;
	/*printf("cor 1 = %f", cor[0]);*/
		
	while(pixel_atual != NULL)
	{
		i = pixel_atual->x; j = pixel_atual->y;
		/*printf("%d ", i);*/
		
		setPixel(R, i, j, cor[0]);
		setPixel(G, i, j, cor[1]);
		setPixel(B, i, j, cor[2]);
		pixel_atual = pixel_atual->prox;
	}
}
开发者ID:renatocf,项目名称:MAC0122,代码行数:23,代码来源:mondrian_com_print.c

示例15: getWidth

void Framebuffer::scroll(int16_t dx, int16_t dy) {
    uint16_t w = getWidth();
    uint16_t h = getHeight();

    uint16_t ax = abs(dx);
    uint16_t ay = abs(dy);

    if (ay == 0) {
        for (uint16_t y = 0; y < h; y++) {
            if (dx < 0) {
                for (uint16_t x = 0; x < w - ax; x++) {
                    uint16_t col = bgColorAt(x + ax, y);
                    setPixel(x, y, col);
                }
            } else {
                for (uint16_t x = 0; x < w - ax; x++) {
                    uint16_t col = bgColorAt(w - (x + ax), y);
                    setPixel(w - x, y, col);
                }
            }
        }
    }
}
开发者ID:enki1986,项目名称:TFT,代码行数:23,代码来源:Framebuffer.cpp


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