本文整理汇总了C++中setpixel函数的典型用法代码示例。如果您正苦于以下问题:C++ setpixel函数的具体用法?C++ setpixel怎么用?C++ setpixel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setpixel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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;
}
}
示例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);
}
}
}
示例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);
}
}
}
}
}
示例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);
}
}
示例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);
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
示例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;
}
}
}
示例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);
}