本文整理汇总了C++中draw_pixel函数的典型用法代码示例。如果您正苦于以下问题:C++ draw_pixel函数的具体用法?C++ draw_pixel怎么用?C++ draw_pixel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了draw_pixel函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: labs
void InterpolateVideo::draw_line(VFrame *frame, int x1, int y1, int x2, int y2)
{
int w = labs(x2 - x1);
int h = labs(y2 - y1);
//printf("InterpolateVideo::draw_line 1 %d %d %d %d\n", x1, y1, x2, y2);
if(!w && !h)
{
draw_pixel(frame, x1, y1);
}
else
if(w > h)
{
// Flip coordinates so x1 < x2
if(x2 < x1)
{
y2 ^= y1;
y1 ^= y2;
y2 ^= y1;
x1 ^= x2;
x2 ^= x1;
x1 ^= x2;
}
int numerator = y2 - y1;
int denominator = x2 - x1;
for(int i = x1; i < x2; i++)
{
int y = y1 + (int64_t)(i - x1) * (int64_t)numerator / (int64_t)denominator;
draw_pixel(frame, i, y);
}
}
else
{
// Flip coordinates so y1 < y2
if(y2 < y1)
{
y2 ^= y1;
y1 ^= y2;
y2 ^= y1;
x1 ^= x2;
x2 ^= x1;
x1 ^= x2;
}
int numerator = x2 - x1;
int denominator = y2 - y1;
for(int i = y1; i < y2; i++)
{
int x = x1 + (int64_t)(i - y1) * (int64_t)numerator / (int64_t)denominator;
draw_pixel(frame, x, i);
}
}
//printf("InterpolateVideo::draw_line 2\n");
}
开发者ID:knutj,项目名称:cinelerra,代码行数:53,代码来源:interpolatevideo.C
示例2: draw_rect
void draw_rect(int x1, int y1, int width, int height, color_t c) {
int vert =0;
int hori = 0;
for(hori = x1; hori < width+x1; hori++) {
draw_pixel(hori,y1,c);
draw_pixel(hori,y1+height,c);
}
for(vert =y1; vert<height+y1; vert++) {
draw_pixel(x1, vert, c);
draw_pixel(x1+width, vert,c);
}
}
开发者ID:Chris-grant1995,项目名称:CS1550,代码行数:12,代码来源:library.c
示例3: draw_line
void
draw_line(
color24_t c,
uint32_t x0,
uint32_t y0,
uint32_t x1,
uint32_t y1
)
{
const int32_t dx = abs(x1 - x0);
const int32_t dy = abs(y1 - y0);
const int32_t sx = x0 < x1 ? 1 : -1;
const int32_t sy = y0 < y1 ? 1 : -1;
int32_t err = dx - dy;
#if VSCREEN_SHIFT != 0
uint32_t last_px = -1;
uint32_t last_py = -1;
#endif
while(1)
{
#if VSCREEN_SHIFT != 0
uint32_t px = x0 >> VSCREEN_SHIFT;
uint32_t py = y0 >> VSCREEN_SHIFT;
if (px != last_px || py != last_py)
{
last_px = px;
last_py = py;
draw_pixel(c, x0, y0);
}
#else
draw_pixel(c, x0, y0);
#endif
if (x0 == x1 && y0 == y1)
break;
int32_t e2 = 2 * err;
if (e2 > -dy)
{
err -= dy;
x0 += sx;
}
if (e2 < +dx)
{
err += dx;
y0 += sy;
}
}
}
开发者ID:pchickey,项目名称:arrow-watch,代码行数:51,代码来源:draw.c
示例4: draw_rect
void draw_rect(int x1, int y1, int width, int height, color_t c){
int x = 0;
int y = 0;
for(x = x1; x <= width+1; x++){
draw_pixel(x, y1, c);
draw_pixel(x, y1 + height, c);
}
for(y = y1; y <= height+2; y++){
draw_pixel(x1, y, c);
draw_pixel(x1 + width, y, c);
}
}
开发者ID:D-Land,项目名称:operating-systems,代码行数:14,代码来源:library.c
示例5: memset
bool Pattern_peak_spike::display()
{
#undef LOG_PEAKS
#ifdef LOG_PEAKS
const int max_dots = 64;
char dots[max_dots + 2];
memset(dots, ' ', sizeof(dots));
dots[max_dots] = '|';
dots[max_dots + 1] = '\0';
memset(dots, '.', get_mapped_peak(max_dots));
Serial.printf("peak %5u %s\n", get_peak(), dots);
#endif
Colour c = make_hue(g_hue.get());
int leds = get_mapped_peak(LED_COUNT / 2);
#define FADE_PEAK
#ifdef FADE_PEAK
static Value held_leds(0, 0, LED_COUNT / 2);
held_leds.set_velocity(-10, 60);
if (leds > held_leds.get()) {
held_leds.set(leds);
}
leds = held_leds.get();
#endif
// Start drawing out from the bottom middle both up and horizontally.
int start_x = COLUMN_COUNT / 2;
int start_y = ROW_COUNT - 1;
int x = start_x;
int y = start_y;
for (int led = 0; led < leds; ++led) {
draw_pixel(x, y, c);
draw_pixel(flip_x(x), y, c);
++x;
++y;
if (x >= COLUMN_COUNT || y >= ROW_COUNT) {
--start_y;
if (start_y < 0) {
start_y = 0;
++start_x;
}
x = start_x;
y = start_y;
}
}
return true;
}
开发者ID:moonfall,项目名称:lush,代码行数:50,代码来源:pattern_peak_spike.cpp
示例6: draw_blocks
static void inline draw_blocks(uint8_t blocks[][4]) {
uint8_t i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
if (blocks[i][j]) {
draw_pixel(2*i, j+4, cff5500);
draw_pixel(2*i+1, j+4, cff5500);
} else {
draw_pixel(2*i, j+4, c000000);
draw_pixel(2*i+1, j+4, c000000);
}
}
}
}
开发者ID:nelfin,项目名称:yameggyjros,代码行数:14,代码来源:breakmeggy.c
示例7: draw_line
/**
* @param surface cíl
* @param x1 počáteční souřadnice úsečky
* @param y1 počáteční souřadnice
* @param x2 koncové souřadnice úsečky
* @param y2 koncové souřadnice úsečky
* @param color barva úsečky
*/
void draw_line(SDL_Surface* surface, int x1, int y1, int x2, int y2, SDL_Color color){
// pres parametrickou rovnici usecky
// kazdy bod Z usecky AB se spocita
// Z = A + (B-A)t
// pro 0<= t <= 1
int length, w=(x2-x1), h=(y2-y1), t;
// length= sqrt(w^2+h^2);
length= w*w + h*h;
for( t=0 ; t*t<length ; ++t); length=t;
// vhodne zdrobnely parametr vykresli dostatecne mnoho pixelu
if(length){
for( t=0 ; t<=length ; ++t )
draw_pixel(surface, x1 + w*t/length, y1 + h*t/length ,color);
} else draw_pixel(surface, x1, y1 ,color);
}
开发者ID:jirkadanek,项目名称:bombic2,代码行数:23,代码来源:SDL_lib.cpp
示例8: print_character
void print_character(uint16_t *colour_ptr, uint32_t x, uint32_t y, volatile unsigned char *fb) {
for (int i = 0; i < CHAR_WIDTH; ++i) {
for (int j = 0; j < CHAR_HEIGHT; ++j) {
draw_pixel(x + j, y + i, fb, colour_ptr[j + (i * CHAR_WIDTH)]);
}
}
}
开发者ID:group34-2016,项目名称:Baremetal-Pac-Man,代码行数:7,代码来源:print_number.c
示例9: draw_pixel
void
Canvas::fill_rect(uint8_t x, uint8_t y, uint8_t width, uint8_t height)
{
for (uint8_t i = 0; i < width; i++)
for (uint8_t j = 0; j < height; j++)
draw_pixel(x + i, y + j);
}
开发者ID:niesteszeck,项目名称:Cosa,代码行数:7,代码来源:Canvas.cpp
示例10: smooth_buffer
void smooth_buffer(struct pixel_buffer* pix) {
int x,y;
for (x = 0; x < pix->width; x++) {
for (y = 0; y < pix->height; y++) {
int left = (x - 1) % pix->width;
int right = (x + 1) % pix->width;
int up = (y - 1) % pix->height;
int down = (y + 1) % pix->height;
if (left < 0) {
left = left + pix->width;
}
if (up < 0) {
up = up + pix->height;
}
Uint32 val = (get_pixel(pix, x, up) + get_pixel(pix, x, down) + get_pixel(pix, left, y) + get_pixel(pix, right, y)) / 4;
draw_pixel(pix, x, y, val);
}
}
}
开发者ID:flightcrank,项目名称:demo-effects,代码行数:29,代码来源:main.c
示例11: fract_j
static void fract_j(t_env *env, t_fract fr)
{
double rn1;
double in1;
double rn;
double in;
int a;
rn1 = 2.0 * (fr.x - env->win_x / 2) / (0.5 * env->zoom * env->win_x) +
env->pos_x;
in1 = (fr.y - env->win_y / 2) / (0.5 * env->zoom * env->win_y) + env->pos_y;
a = -1;
while (++a < (env->iter - 1))
{
rn = rn1;
in = in1;
rn1 = (rn * rn) - (in * in) + fr.rc;
in1 = 2 * rn * in + fr.ic;
if ((rn1 * rn1 + in1 * in1) > 4)
break ;
}
get_color_palette(env, env->color, a, env->pal);
if ((fr.x >= 0 && fr.x < env->win_x) && (fr.y >= 0 && fr.y < env->win_y)
&& a < (env->iter - 1))
draw_pixel(env, fr.x, fr.y, env->color);
}
开发者ID:aputman-Raptor,项目名称:fract-ol,代码行数:26,代码来源:julia.c
示例12: draw_wall
static void draw_wall(t_event *e, t_raycast *rc, t_vec2 *p, int line_height)
{
int color;
int id;
if (!e->texture_mode)
{
if (rc->side)
color = rc->step.y > 0 ? 0xff0000 : 0xffff00;
else
color = rc->step.x > 0 ? 0x00ff00 : 0x00ffff;
}
else
{
id = e->game.map[rc->map.y][rc->map.x];
rc->tex.y = (p->y * 2 - e->height + line_height)
* (e->textures[id].height / 2) / line_height;
color = e->textures[id].data[rc->tex.y
* e->textures[id].width + rc->tex.x];
if (rc->side)
color = color_fusion(color, 0x0f0f0f);
else
color = color_fusion(color, 0x1f1f1f);
}
draw_pixel(e, p->x, p->y, color);
free(p);
}
开发者ID:mimusangel,项目名称:wolf3d,代码行数:27,代码来源:rc_render.c
示例13: draw_xy
static inline void draw_xy(int x, int y,
unsigned char r,
unsigned char g,
unsigned char b)
{
draw_pixel(x + centerX, centerY - y, r, g, b);
}
开发者ID:doremi,项目名称:sdl,代码行数:7,代码来源:anim.c
示例14: press_event
void press_event(MouseEvent ev)
{
pressed = true;
draw_pixel(ev.x, ev.y);
last_x = ev.x;
last_y = ev.y;
}
开发者ID:Siemko,项目名称:PIU,代码行数:7,代码来源:main.cpp
示例15: draw_bitmap
void draw_bitmap(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint16_t *sprite, volatile unsigned char *fb) {
for (int i = 0; i < width; ++i) {
for (int j = 0; j < height; ++j) {
draw_pixel(x + i, y + j, fb, sprite[i + (width * j)]);
}
}
}
开发者ID:group34-2016,项目名称:Baremetal-Pac-Man,代码行数:7,代码来源:title_screen.c
示例16: draw_element
static void draw_element(int x,int y,const char element[8][8],char angle){
x = x * SNAKE_ELEMENT_SIZE;
y = y * SNAKE_ELEMENT_SIZE;
int xx,yy;
for(xx=0;xx<SNAKE_ELEMENT_SIZE;xx++)
for(yy=0;yy<SNAKE_ELEMENT_SIZE;yy++){
char c = COLOR_RED;
char col = 0;
if(angle == 0) col = element[yy][xx];
if(angle == 1) col = element[xx][7-yy];
if(angle == 2) col = element[xx][yy];
if(angle == 3) col = element[yy][7-xx];
if(angle == 4) col = element[7-xx][yy];
switch(col){
case 'R': c = COLOR_RED; break;
case 'G': c = COLOR_GREEN; break;
case 'B': c = COLOR_BLACK; break;
case 'b': c = COLOR_BLUE; break;
case 'Y': c = COLOR_YELLOW; break;
case 'O': c = 0x28; break;
default: c = COLOR_WHITE; break;
};
draw_pixel( x+xx, y+yy, c );
}
}
开发者ID:BioDesignRealWorld,项目名称:CHDK,代码行数:26,代码来源:gui_snake.c
示例17: draw_blank_tile
void draw_blank_tile(int x_pos, int y_pos, volatile unsigned char *fb) {
for (int y = 0; y < 8; ++y) {
for (int x = 0; x < 8; ++x) {
draw_pixel(x + x_pos + X_OFFSET_GAME, y + y_pos + Y_OFFSET_GAME, fb, 0);
}
}
}
开发者ID:group34-2016,项目名称:Baremetal-Pac-Man,代码行数:7,代码来源:render.c
示例18: draw_score_sprite
void draw_score_sprite(int point, int offset, ghost *ghost_ptr, volatile unsigned char *fb) {
Sprite *score = (Sprite *) malloc(sizeof(Sprite));
score->height = 16;
score->width = 16;
switch(point) {
case 200:
score->bitmap = points_200;
break;
case 400:
score->bitmap = points_400;
break;
case 800:
score->bitmap = points_800;
break;
case 1600:
score->bitmap = points_1600;
break;
}
int x_pos = ghost_ptr->x;
int y_pos = ghost_ptr->y + offset;
x_pos -= 9;
y_pos -= 9;
int width = score->width;
int height = score->height;
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
if(*(score->bitmap + x + (y * width))) {
draw_pixel(x + x_pos + X_OFFSET_GAME, y + y_pos + Y_OFFSET_GAME, fb, *(score->bitmap + x + (y * width)));
}
}
}
free(score);
}
开发者ID:group34-2016,项目名称:Baremetal-Pac-Man,代码行数:33,代码来源:render.c
示例19: jpeg_output
// ********************************************
void jpeg_output(const char * fname, int x0, int y0, int dx, int dy)
{
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
FILE *infile;
JSAMPARRAY buffer;
int i,j,x=x0,y=y0;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
if((infile = fopen(fname,"rb")) == NULL) {
printf("Error: can't open file: %s\n", fname);
return;
}
jpeg_stdio_src(&cinfo, infile);
jpeg_read_header(&cinfo, TRUE);
jpeg_start_decompress(&cinfo);
buffer=(*cinfo.mem->alloc_sarray)((j_common_ptr) &cinfo, JPOOL_IMAGE, cinfo.output_width*cinfo.output_components, 1);
i=cinfo.output_width*cinfo.output_components*sizeof(char);
while(cinfo.output_scanline < cinfo.output_height) {
jpeg_read_scanlines(&cinfo, buffer, 1);
j=0;
while(j<=i) {
if ((x<(x0+dx))&&((y<(y0+dy))))
draw_pixel(x, y, buffer[0][j],buffer[0][j+1],buffer[0][j+2]);
j+=3;
x++;
}
y++;
x=x0;
}
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
fclose(infile);
}
开发者ID:boerge42,项目名称:rpi_gui,代码行数:36,代码来源:globals.c
示例20: draw_filled_rect_buffer
void draw_filled_rect_buffer(GBitmap *buffer, GRect rect, GColor color) {
for(int x = rect.origin.x; x < rect.origin.x + rect.size.w; x++){
for(int y = rect.origin.y; y < rect.origin.y + rect.size.h; y++){
draw_pixel(buffer, GPoint(x, y), color);
}
}
}
开发者ID:tolma488,项目名称:metro-spb,代码行数:7,代码来源:FBDraw.c
注:本文中的draw_pixel函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论