Synopsis: plot(brush,width,height,x,y,mode)
plot(imgbuff,x,y,mode)
The first form uses a byte array containing the brush shape.
The second form uses another ImageBuff object as a brush.
The ImageBuff object must be initialized before you can call
these methods. Use load(rgb_buffer,sizex,sizey) method to create
an image buffer of given size (with alpha channel set to 255).
The brush is plotted directly in the image buffer. The texture
is updated only when the VideoTexture.Texture parent object is
refreshed: this will download the image buffer to the GPU.
brush: Byte array containing RGBA data to be plotted in image buffer.
The data must be continuous in memory, organized row by row
starting from lower left corner of the image. Each pixel is
4 bytes representing RGBA data in that order.
width: Horizontal size in pixels of image in brush.
height: Vertical size in pixels of the image in brush.
imgbuff:Another ImageBuff object that is used as a brush. The object
must have been initialized first with load().
x: Horizontal position in pixel from left side of the image buffer
where the brush will be plotted. The brush is plotted on pixels
positions x->x+width-1. Clipping is performed if the brush falls
partially outside the image buffer.
y: Vertical position in pixel from bottom side of the image buffer
where the brush will be plotted.
mode: Mode of drawing. Use one of the following value:
0 : MIX
1 : ADD
2 : SUB
3 : MUL
4 : LIGHTEN
5 : DARKEN
6 : ERASE ALPHA
7 : ADD ALPHA
1000 : COPY RGBA (default)
1001 : COPY RGB
1002 : COPY ALPHA
Modes 0 to 7 are 'blend' modes: the brush pixels are combined
with the image pixel in various ways. Refer to Blender documentation
to learn more about these modes.
60 lines
1.8 KiB
C++
60 lines
1.8 KiB
C++
/* $Id$
|
|
-----------------------------------------------------------------------------
|
|
This source file is part of VideoTexture library
|
|
|
|
Copyright (c) 2007 The Zdeno Ash Miklas
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
the terms of the GNU Lesser General Public License as published by the Free Software
|
|
Foundation; either version 2 of the License, or (at your option) any later
|
|
version.
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License along with
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
|
http://www.gnu.org/copyleft/lesser.txt.
|
|
-----------------------------------------------------------------------------
|
|
*/
|
|
|
|
#if !defined IMAGEBUFF_H
|
|
#define IMAGEBUFF_H
|
|
|
|
|
|
#include "Common.h"
|
|
|
|
#include "ImageBase.h"
|
|
|
|
struct ImBuf;
|
|
|
|
/// class for image buffer
|
|
class ImageBuff : public ImageBase
|
|
{
|
|
private:
|
|
struct ImBuf* m_imbuf; // temporary structure for buffer manipulation
|
|
public:
|
|
/// constructor
|
|
ImageBuff (void) : ImageBase(true), m_imbuf(NULL) {}
|
|
|
|
/// destructor
|
|
virtual ~ImageBuff (void);
|
|
|
|
/// load image from buffer
|
|
void load (unsigned char * img, short width, short height);
|
|
|
|
/// plot image from extern RGBA buffer to image at position x,y using one of IMB_BlendMode
|
|
void plot (unsigned char * img, short width, short height, short x, short y, short mode);
|
|
/// plot image from other ImageBuf to image at position x,y using one of IMB_BlendMode
|
|
void plot (ImageBuff* img, short x, short y, short mode);
|
|
|
|
/// refresh image - do nothing
|
|
virtual void refresh (void) {}
|
|
};
|
|
|
|
|
|
#endif
|
|
|