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


C++ set_pixel函数代码示例

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


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

示例1: graphics_worker_thread

int graphics_worker_thread(graphics_worker_arg *arg){
    graphics_state *state = arg->state;
    int x0 = state->worker_pixel_ranges[4*arg->i];
    int y0 = state->worker_pixel_ranges[4*arg->i + 1];
    int x1 = state->worker_pixel_ranges[4*arg->i + 2];
    int y1 = state->worker_pixel_ranges[4*arg->i + 3];

    /* raytrace */
    while(1){
        SDL_SemWait(state->sema_start_render);

        int x, y;
        for(y = y0; y < y1; y++) 
        {
            int ytimesw = y * state->width;
            for(x = x0; x < x1; x++) 
            {
                if(!state->stencil[x + ytimesw]){
                    set_pixel(state, x, ytimesw, 0, 0, 0);
                    continue;
                }

                f3 color = graphics_render_pixel(state, x, y);
                set_pixel(state, x, ytimesw, 
                    (Uint8)(color.x*255.9f),
                    (Uint8)(color.y*255.9f),
                    (Uint8)(color.z*255.9f));
            }
        }

        /* let the main thread know we're done rendering */
        SDL_SemPost(state->sema_finish_render);
    }
    return 0;
}
开发者ID:dcposch,项目名称:simple_spheres,代码行数:35,代码来源:demo.c

示例2: clear

  void PixelMap::load(const Image &image)
  {
    clear();

    size = image.getSize();

    map = new u8*[size.getHeight()];

    for(int y = 0; y < size.getHeight(); y++)
    {
      int linelength;

      linelength = size.getWidth()%8 == 0 ? size.getWidth()/8 : size.getWidth()/8 + 1;

      map[y] = new u8[linelength];
        memset(map[y], 0, sizeof(*map[y]) * linelength);

      for(int x = 0; x < size.getWidth(); x++)
      {
        if(!image.hasColorkey())
          set_pixel(x, y, 1);
        else if(image.getPixel(IntPoint(x, y)) != image.getColorkey())
          set_pixel(x, y, 1);
      }
    }

  }
开发者ID:mrzzzrm,项目名称:shootet,代码行数:27,代码来源:PixelMap.cpp

示例3: draw_line

void draw_line(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2) {
	if (x1 == x2) {
		// Draw vertical line
		for (int i = y1; (y2 > y1) ? i <= y2 : i >= y2; (y2 > y1) ? i++ : i-- ) {
			set_pixel(x1, i, 1);
		}
	} else if (y1 == y2) {
		// Draw horizontal line
		for (int i = x1; (x2 > x1) ? i <= x2 : i >= x2; (x2 > x1) ? i++ : i-- ) {
			set_pixel(i, y1, 1);
		}
	} else {
		// Get Bresenhaming...
		float dx = x2-x1;
		float dy = y2-y1;
		float err = 0.0;
		float derr = ABS(dy/dx);

		for (int x = x1, y = y1; (dx > 0) ? x<=x2 : x>=x2; (dx > 0) ? x++ : x--) {
			set_pixel(x, y, 1);
			err += derr;
			while (err >= 0.5 && ((dy > 0) ? y<=y2 : y>=y2) ) {
				set_pixel(x, y, 1);
				y += (dy > 0) - (dy < 0);
				err -= 1.0;
			}
		}
	}
}
开发者ID:0xLeon,项目名称:CAB202-Projects,代码行数:29,代码来源:graphics.c

示例4: main

int main(int argc, char* argv[])
{
	create_image_world();
	
	int image = create_image(100, 100);
	
	for(int x = 0; x < 100; x++)
	{
		for(int y = 0; y < 100; y++)
		{
			if (x == y)
			{
				set_pixel(image, x, y, 255, 0, 0, 255);
			}
			else if (x+y == 100)
			{
				set_pixel(image, x, y, 255, 255, 0, 0);
			}
			else
			{
				set_pixel(image, x, y, 255, 0, 255, 0);
			}
		}
	}
	
	put_image(image, get_screen_width()/2-get_image_width(image)/2, get_screen_height()/2-get_image_height(image)/2);
	
	return p1world_shutdown();	
}
开发者ID:chadhao,项目名称:Programming1,代码行数:29,代码来源:hw06q05.c

示例5: generic_expand_bitmap

void generic_expand_bitmap(u32 x, u32 y, u32 width, u32 height, const u8 *data,
			   u32 pitch, pixel_t pixel0, pixel_t pixel1)
{
    u32 w, x0;
    const u8 *data0;
    int i;
    u8 bits;

    while (height--) {
	w = width;
	x0 = x;
	data0 = data;
	while (w > 7) {
	    bits = *data0++;
	    for (i = 0; i < 8; i++, bits <<= 1)
		set_pixel(x0++, y, bits & 0x80 ? pixel1 : pixel0);
	    w -= 8;
	}
	if (w > 0) {
	    bits = *data0++;
	    while (w-- > 0) {
		set_pixel(x0++, y, bits & 0x80 ? pixel1 : pixel0);
		bits <<= 1;
	    }
	}
	y++;
	data += pitch;
    }
}
开发者ID:HackLinux,项目名称:device_driver_test,代码行数:29,代码来源:generic.c

示例6: draw_box

void draw_box(unsigned char box_num, unsigned char draw_open) {
    // Figure out box information
    unsigned char c_x, c_y, min_x, max_x, min_y, max_y;
    c_x = LCD_X * (box_num%BOXES_W + 0.5f) / ((float) BOXES_W);
    c_y = LCD_Y * (box_num/BOXES_W + 0.5f) / ((float) BOXES_H);
    min_x = c_x-BOX_RADIUS;
    max_x = c_x+BOX_RADIUS;
    min_y = c_y-BOX_RADIUS;
    max_y = c_y+BOX_RADIUS;

    // Draw the open or closed box
    if (draw_open) {
        // Draw the outlined box
        for (unsigned char x=min_x; x<=max_x; x++) {
            for (unsigned char y=min_y; y<=max_y; y++) {
                set_pixel(x, y, (x==min_x || x==max_x || y==min_y || y==max_y) ? 1 : 0);
            }
        }

        // Draw the character
        draw_char(c_x-2, c_y-3, (is_gold[box_num]) ? '$' : 'X');
    } else {
        // Draw the filled box
        for (unsigned char x=min_x; x<=max_x; x++) {
            for (unsigned char y=min_y; y<=max_y; y++) {
                set_pixel(x, y, 1);
            }
        }
    }
}
开发者ID:trjstewart,项目名称:qut-cab202,代码行数:30,代码来源:question_4.c

示例7: generic_copy_rect

void generic_copy_rect(u32 dx, u32 dy, u32 width, u32 height, u32 sx, u32 sy)
{
    u32 w, dx0, sx0;

    if (dy > sy || (dy == sy && dx > sx)) {
	dx += width;
	dy += height;
	sx += width;
	sy += height;
	while (height--) {
	    dy--;
	    sy--;
	    for (w = width, dx0 = dx, sx0 = sx; w > 0; w--) {
		dx0--;
		sx0--;
		set_pixel(dx0, dy, get_pixel(sx0, sy));
	    }
	}
    } else {
	while (height--) {
	    for (w = width, dx0 = dx, sx0 = sx; w > 0; w--) {
		set_pixel(dx0, dy, get_pixel(sx0, sy));
		dx0++;
		sx0++;
	    }
	    dy++;
	    sy++;
	}
    }
}
开发者ID:HackLinux,项目名称:device_driver_test,代码行数:30,代码来源:generic.c

示例8: draw_label

void draw_label(image a, int r, int c, image label, image prob_label, const float *rgb)
{
    float ratio = (float) label.w / label.h;
    int h = label.h;
    int w = ratio * h;
    image rl = resize_image(label, w, h);
    if (r - h >= 0) r = r - h;
    float ratiop = (float) prob_label.w / prob_label.h;
    int hp = prob_label.h;
    int wp = ratiop * hp;
    image rpl = resize_image(prob_label, wp, hp);

    int i, j, k;
    for(j = 0; j < h && j + r < a.h; ++j){
        for(i = 0; i < w && i + c < a.w; ++i){
            for(k = 0; k < label.c; ++k){
                float val = get_pixel(rl, i, j, k);
                set_pixel(a, i+c+50, j+r, k, rgb[k] * val);
            }
        }
    }
    for(j = 0; j < hp && j + r < a.h; ++j){
        for(i = 0; i < wp && i + c < a.w; ++i){
            for(k = 0; k < prob_label.c; ++k){
                float val = get_pixel(rpl, i, j, k);
                set_pixel(a, i+c, j+r, k, rgb[k] * val);
            }
        }
    }
    free_image(rl);
    free_image(rpl);
}
开发者ID:jjmata,项目名称:cvjena-darknet,代码行数:32,代码来源:image.c

示例9: rgb_to_hsv

// http://www.cs.rit.edu/~ncs/color/t_convert.html
void rgb_to_hsv(image im)
{
    assert(im.c == 3);
    int i, j;
    float r, g, b;
    float h, s, v;
    for(j = 0; j < im.h; ++j){
        for(i = 0; i < im.w; ++i){
            r = get_pixel(im, i , j, 0);
            g = get_pixel(im, i , j, 1);
            b = get_pixel(im, i , j, 2);
            float max = three_way_max(r,g,b);
            float min = three_way_min(r,g,b);
            float delta = max - min;
            v = max;
            if(max == 0){
                s = 0;
                h = -1;
            }else{
                s = delta/max;
                if(r == max){
                    h = (g - b) / delta;
                } else if (g == max) {
                    h = 2 + (b - r) / delta;
                } else {
                    h = 4 + (r - g) / delta;
                }
                if (h < 0) h += 6;
            }
            set_pixel(im, i, j, 0, h);
            set_pixel(im, i, j, 1, s);
            set_pixel(im, i, j, 2, v);
        }
    }
}
开发者ID:renmengye,项目名称:darknet,代码行数:36,代码来源:image.c

示例10: game_of_life

void game_of_life() {
    int x;
    int y;
    for (x = 0; x < SW_VGA_WIDTH; ++x) {
        for (y = 0; y < SW_VGA_HEIGHT; ++y) {
            int n = neighbors(old_img_addr, x, y);
            /* if is alive */
            if (get_pixel(old_img_addr, x, y)) {
                /* underpopulation or overcrowding: die */
                if ((n < 2) || (n > 3)) {
                    set_pixel(new_img_addr, x, y, 0);
                } else {
                    set_pixel(new_img_addr, x, y, 1);
                }
            } else {
                /* perfect conditions: become alive */
                if (n == 3) {
                    set_pixel(new_img_addr, x, y, 1);
                } else {
                    set_pixel(new_img_addr, x, y, 0);
                }
            }
        }
    }
}
开发者ID:elkhadiy,项目名称:cours-tlm,代码行数:25,代码来源:main.c

示例11: generic_draw_line

void generic_draw_line(u32 x1, u32 y1, u32 x2, u32 y2, pixel_t pixel)
{
    int dx, dy, sx, sy, e;

    dx = x2-x1;
    dy = y2-y1;
    if (dy == 0) {
	if (dx < 0) {
	    dx = -dx;
	    x1 = x2;
	}
	draw_hline(x1, y1, dx+1, pixel);
    } else if (dx == 0) {
	if (dy < 0) {
	    dy = -dy;
	    y1 = y2;
	}
	draw_vline(x1, y1, dy+1, pixel);
    } else {
	if (dy < 0) {
	    dy = -dy;
	    sy = -1;
	} else {
	    sy = 1;
	}
	if (dx < 0) {
	    dx = -dx;
	    sx = -1;
	} else {
	    sx = 1;
	}
	if (dx > dy) {
	    e = -dx/2;
	    set_pixel(x1, y1, pixel);
	    while (x1 != x2) {
		e += dy;
		if (e >= 0) {
		    y1 += sy;
		    e -= dx;
		}
		x1 += sx;
		set_pixel(x1, y1, pixel);
	    }
	} else {
	    e = -dy/2;
	    set_pixel(x1, y1, pixel);
	    while (y1 != y2) {
		e += dx;
		if (e >= 0) {
		    x1 += sx;
		    e -= dy;
		}
		y1 += sy;
		set_pixel(x1, y1, pixel);
	    }
	}
    }
}
开发者ID:HackLinux,项目名称:device_driver_test,代码行数:58,代码来源:generic.c

示例12: fill_circle_points_x

static void fill_circle_points_x(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel)
{
    if (x == 0) {
	set_pixel(cx, cy-y, pixel);
	set_pixel(cx, cy+y, pixel);
    } else {
	draw_hline(cx-x, cy-y, 2*x+1, pixel);
	draw_hline(cx-x, cy+y, 2*x+1, pixel);
    }
}
开发者ID:HackLinux,项目名称:device_driver_test,代码行数:10,代码来源:generic.c

示例13: fill_ellipse_points

static void fill_ellipse_points(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel)
{
    if (x == 0) {
	set_pixel(cx, cy-y, pixel);
	set_pixel(cx, cy+y, pixel);
    } else if (y == 0) {
	draw_hline(cx-x, cy, 2*x+1, pixel);
    } else {
	draw_hline(cx-x, cy-y, 2*x+1, pixel);
	draw_hline(cx-x, cy+y, 2*x+1, pixel);
    }
}
开发者ID:HackLinux,项目名称:device_driver_test,代码行数:12,代码来源:generic.c

示例14: get_pixel

void UnaryCompositeLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
                                               const vector<Blob<Dtype>*>& top)
{
    top[0]->CopyFrom(*bottom[0], false);// data is copied
    
    Dtype user_interaction_potential = this->layer_param_.multi_stage_crf_param().user_interaction_potential();
    Dtype dis_mean = this->layer_param_.multi_stage_crf_param().interaction_dis_mean();
    Dtype dis_std  = this->layer_param_.multi_stage_crf_param().interaction_dis_std();
    Dtype dis_cv = dis_mean/dis_std;
    
    const Dtype * bottom_data = bottom[0]->cpu_data();
    const Dtype * image_data = bottom[1]->cpu_data();
    Dtype * top_data = top[0]->mutable_cpu_data();
    Dtype * mask_data = top[1]->mutable_cpu_data();
    int scribble_point = 0;
    for(int n=0; n<num_; n++)
    {
        for(int h=0; h<height_; h++)
        {
            for(int w=0; w<width_; w++)
            {
                int scribble_channel = -1;
                for(int c = 0; c<unary_channels_; c++)
                {
                    int ci = image_channels_-unary_channels_ + c;
                    Dtype d = get_pixel(image_data, num_, image_channels_, height_, width_,
                                        n, ci, h, w);
                    if((d + dis_cv) < 1e-5 && (d + dis_cv) > -1e-5)
                    {
                        scribble_channel = c;
                        scribble_point++;
                        break;
                    }
                }
                
                Dtype mask_value = (scribble_channel>-1)? 1.0 : 0.0;
                set_pixel(mask_data, num_, 1, height_, width_, n, 0, h, w, mask_value);
                if(scribble_channel > -1)
                {
                    for (int c = 0; c<unary_channels_; c++)
                    {
                        Dtype u_value = 0;//get_pixel(bottom_data, num_, unary_channels_, height_, width_,n, c, h, w);
                        u_value = (c == scribble_channel)? u_value + user_interaction_potential :
                                                           u_value - user_interaction_potential;
                        set_pixel(top_data, num_, unary_channels_, height_, width_, n, c, h, w, u_value);
                    }
                }
            } //for w
        } // for h
    } // for n
    LOG(INFO)<<"scribble point: "<<scribble_point;
}
开发者ID:taigw,项目名称:caffe,代码行数:52,代码来源:unary_composite.cpp

示例15: draw_circle

void draw_circle(SDL_Surface *surface, int cx, int cy, int radius, Uint32 pixel) {
    double r = (double)radius;

    for(double dy = 1; dy <= r; dy += 1.0) {
        double dx = floor(sqrt((2.0 * r * dy) - (dy * dy)));
        int x = cx - dx;

        for(; x <= cx + dx; x++) {
            set_pixel(surface, x, ((int)(cy + r - dy)), pixel);
            set_pixel(surface, x, ((int)(cy - r + dy)), pixel);
        }
    }
}
开发者ID:stephanel,项目名称:RadioclockSDL,代码行数:13,代码来源:primitives.c


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