Video Operations

You can use the provided video operations by including:

#include "iimavlib/video_ops.h"

blit

void blit(video_buffer_t& target, const video_buffer_t& src, rectangle_t position);

This method blits (copies) one canvas (or part of it) to other canvas. If position has dimensions specified:

  • The final affected are is calculated as an intersection of position and target.size.
  • The src buffer is the copied to the target, starting at left upper corner.

If position has dimensions lower or equal to zero, then the dimensions are initialized with src.size.width and src.size.height and then used as if they were specified.

Usage:

// Creates a canvas 100x100 pixels, filled with default black color.
iimavlib::video_buffer_t canvas(100, 100);
 
// Red color
iimavlib::rgb_t red_color(255,0,0)
 
// Creates another canvas 80x80 pixels, filled with red color.
iimavlib::video_buffer_t canvas2(80, 80, red_color);
 
// Puts the //canvas2// into //canvas// at position 10x10
iimavlib::blit(canvas, canvas2, iimavlib::rectangle_t(10,10,80,80));

Geometric primitives

There are also several functions to draw a geometric elements to a canvas.

circle
void draw_circle(video_buffer_t& data, rectangle_t rectangle, rgb_t color);

Draws a circle with a specified color. The circle (or ellipse) is bounded by rectangle

// Creates a canvas 100x100 pixels, filled with default black color.
iimavlib::video_buffer_t canvas(100, 100);
// Red color
iimavlib::rgb_t red_color(255,0,0)
 
// Draws a circle with radius 10, with the center at 50x50.
// So the circle has to be inside a rectangle with left upper corner at 40x40, with size 20x20.
iimavlib::draw_circle(canvas, iimavlib::rectangle_t(40,40,20,20),red_color);
rectangle
void draw_rectangle(video_buffer_t& data, rectangle_t rectangle, rgb_t color);
void draw_empty_rectangle(video_buffer_t& data, rectangle_t rectangle, int border, rgb_t color);

Draws a rectangle, specified by the rectangle parameter. draw_rectangle draws a filled rectangle, draw_empty_rectangle draws a rectangle with borders of width border.

lines
void draw_line(iimavlib::video_buffer_t& data, iimavlib::rectangle_t start, iimavlib::rectangle_t end, iimavlib::rgb_t color);
void draw_polyline(iimavlib::video_buffer_t& data, const std::vector<iimavlib::rectangle_t>& points, iimavlib::rgb_t color);
void draw_polygon(iimavlib::video_buffer_t& data, const std::vector<iimavlib::rectangle_t>& points, iimavlib::rgb_t color);

draw_line draws a line. start and end specifies the ends of the line (only x and y attributes are used).

draw_polyline draws a polyline defined by a vector of points.

draw_polygon draws a polyline defined by a vector of points, connecting the last and first points.

 
support/iimavlib/video_ops.txt · Last modified: 2014/03/12 23:40 by neneko
 
Except where otherwise noted, content on this wiki is licensed under the following license: GNU Free Documentation License 1.3
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki