Пример #1
0
static FvsError_t OverlayDirection(FvsImage_t image, const FvsFloatField_t field) {
    FvsError_t nRet = FvsOK;
    FvsInt_t w      = ImageGetWidth (image);
    FvsInt_t h      = ImageGetHeight(image);
    FvsInt_t pitch, dirp;
    FvsFloat_t theta, c, s;
    FvsByte_t* p;
    FvsFloat_t* orientation;
    FvsInt_t x, y, size, i, j, l;
    size = 8;
    (void)ImageLuminosity(image, 168);
    pitch  = ImageGetPitch (image);
    p      = ImageGetBuffer(image);
    orientation = FloatFieldGetBuffer(field);
    dirp        = FloatFieldGetPitch(field);
    if (p == NULL || orientation == NULL)
        return FvsMemory;
    for (y = size; y < h - size; y += size - 2)
        for (x = size; x < w - size; x += size - 2) {
            theta = orientation[x + y * dirp];
            c = cos(theta);
            s = sin(theta);
            for (l = 0; l < size; l++) {
                i = (FvsInt_t)(x + size / 2 - l * s);
                j = (FvsInt_t)(y + size / 2 + l * c);
                p[i + j * pitch] = 0;
            }
        }
    return nRet;
}
Пример #2
0
/* 从RGB888图像数据构造image对象 */
static FvsError_t 
rgb24_to_image(FvsByte_t *rgb24_buf, FvsImage_t image)
{
	FvsByte_t		pal[256];
	FvsByte_t*  	pDest = NULL;
	FvsInt_t    	nMax;
	FvsByte_t   r,g,b;
	FvsInt_t    i;
			
	/* default palette */
	for (i = 0; i < 256; i++)
		pal[i] = (FvsByte_t)i;
		
	pDest = ImageGetBuffer(image);
	if (pDest==NULL)
		return FvsMemory;
	
	nMax = ImageGetWidth(image) * ImageGetHeight(image) * 3;
	for (i = 0; i < nMax; i += 3)
	{
		r = *rgb24_buf++;
		g = *rgb24_buf++;
		b = *rgb24_buf++;
		*pDest++ = pal[((r+(g<<1)+b)>>2)&0xFF];
	}
	
	return FvsOK;
}