// 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()); }
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(); }
// ---------------------------------------------------------------------------- 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
// 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); } }
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; }
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! }
/** 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); } } }
/** * 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); } }
//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)); } }
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); } } }
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); } } }
/** 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++; } }
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); }
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; } }
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); } } } } }
TEST_F(RgbScreenServerTest, testSetPixelViaBinaryStreams) { uint8_t command = RemoteRgbScreenProtocol::SET_PIXEL; uint8_t x = 7; uint8_t y = 6; Color color(60,70,80); Com::BinaryOutputPackage out(mInBuffer); out << command << x << y << color; EXPECT_CALL(mScreen,setPixel(x,y,color)); mRgbScreenServer.handleRequest(mIn,mOutMock); }
void RayTracingImageCudaMOO::fillImageGL() { int w = getW(); int h = getH(); #pragma omp parallel for num_threads(numThreads) for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { setPixel(i, j, t); } } }
void drawChar(int row, int col, unsigned char ch, u16 color) { int r,c; for(r=0; r<8; r++) { for(c=0; c<6; c++) { if(fontdata_6x8[OFFSET(r, c, 6) + ch*48]) { setPixel(r+row, c+col, color); } } } }
void drawChar(int row, int col, char ch, u16 color) { int r,c; for(r=0; r<8; r++) { for(c=0; c<6; c++) { if(fontdata_6x8[ch*48+r*6+c]) { setPixel(row+r, col+c, color); } } } }
void drawChar(int x, int y, char ch, unsigned short color) { int x1, y1; for(x1=0; x1<6; x1++) { for(y1=0; y1<8; y1++) { if(fontdata_6x8[OFFSET2(x1, y1, 6)+ch*48]) { setPixel(x+x1, y+y1, color); } } } }
void drawChar(int row, int col, char ch, unsigned short color) { int r,c; for(r=0; r<8; r++) { for(c=0; c<6; c++) { if(fontdata_6x8[r*6 + c +ch*48]) { setPixel(row+r, col+c, color); } } } }
/** * Converts the RGB Image to GrayScale Image. */ void JPGImage::toGrayScale(){ setGrayScaleAvaliable(true); //The news values of Gray Pixel are copied to the Pixel Matrix for(int x = 0; x < getWidth(); x++){ for(int y = 0; y < getHeight(); y++){ Pixel *p = new Pixel(getPixel(x, y)); p->toGrayScale(); setPixel(x, y, p); delete(p); } } }
//============================================================================== void ICACHE_FLASH_ATTR tft_drawFastHLine(unsigned int x, unsigned int y, unsigned int w, unsigned long color) { // Rudimentary clipping if((x >= _width) || (y >= _height)) return; if((x+w-1) >= _width) w = _width-x; //SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); LCD_setAddr(x, y, x+w-1, y); lcdWrite(COMMAND, RAMWR);//writecommand_cont(ILI9341_RAMWR); while (w-- > 0) { setPixel(color);//writedata16_cont(color); } // writedata16_last(color); // SPI.endTransaction(); }
void Sprite::convertToGreyScale() { SDL_LockSurface(spriteSurface); SDL_Color colorBW; for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { colorBW = tbox.getBWColor(getPixel(spriteSurface, i, j)); setPixel(spriteSurface, i, j, colorBW); } } SDL_UnlockSurface(spriteSurface); regenerateTexture(); }
SDL_Surface* filtre_noir_blanc(t_display display) { int x, y; Uint8 r_s, g_s, b_s, a_s; Uint32 pixel_s; SDL_LockSurface(display.screen); for (y = 0 ; y < display.screen->h; y ++) { for ( x = 0 ; x < display.screen->w; x ++) { pixel_s = *((Uint32*)(display.screen->pixels) + x + y * WINX); SDL_GetRGBA(pixel_s, display.screen->format, &r_s, &g_s, &b_s, &a_s); Uint8 Moyenne = (r_s + g_s + b_s) / 3; if(Moyenne < 120) { r_s = 0; g_s = 0; b_s = 0; } else if(Moyenne >= 120) { r_s = 255; g_s = 255; b_s = 255; } pixel_s = SDL_MapRGBA(display.screen->format, r_s, g_s, b_s, a_s); setPixel(&display, x, y, pixel_s); } } SDL_UnlockSurface(display.screen); SDL_BlitSurface(display.screen, NULL, display.screen, NULL); SDL_Flip(display.screen); return display.screen; }
void RipplingMOO::fillImage(float t) { int h = getH(); int w = getW(); #pragma omp parallel for if ( _omp ) for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { setPixel(i, j, t); } } }
/*Draws an outline of a rectangle of the given color with a given width and height at (r,c) */ void drawHollowRect(int r, int c, int width, int height, u16 color){ int w; int h; //draw the rectangle for(h = 0; h < height; h++){ for(w = 0; w < width; w++){ //set the pixel only if the current pixel is on the outer edges //i.e. on the first or last row, or the first or last column if((h == 0 || h == (height - 1)) || (w == 0 || w == (width - 1))){ setPixel(h + r, w + c, color); } } } }
void drawChar(int row, int col, char ch, u16 color) { int r,c; for(r=0; r<8; r++) { for(c=0; c<6; c++) { if(fontdata_6x8[(r*6+c)+(48*ch)] == 1) { setPixel(row+r, col+c, color); } } } }
/* Place a row representing a binary number on the matrix b - value to convert to binary representation r, c - row/col in matrix d - digits (columns) to use for binary number co - color value br - brightness value */ void LedMatrixClass::placeBinary(int b, int r, int c, int p) { int rtmp, gtmp, btmp; for (int i = 0; i < p; ++i) // only need 'p' LSB from number { if (b & (0x01 << i)) setPixel(r, c + p - 1 - i); else clearPixel(r, c + p - 1 - i); } return; }
void drawBuffer(bufferPt *buffer, HWND sHwnd) { int width = buffer->width; int height = buffer->height; int x, y; COLORREF color; for (int i = 0; i < width * height; i++) { y = (i / height); x = (i % width); color = buffer->pixels[(y * width) + x]; if (color) { setPixel(x, y, color, sHwnd); } } }