Esempio n. 1
0
void meter_free(t_meter *x)
{	
	dsp_freejbox((t_pxjbox *)x);
	jgraphics_surface_destroy(x->gradientSurface);
	object_free((t_object *)x->clock);
	jbox_free((t_jbox *)x);
}
Esempio n. 2
0
void meterCacheSurface(t_meter* x)
{
	t_jrgba	color;
	t_jbox*	box = (t_jbox*)x;
	int		i, j;
	
	x->gradientRect.x = 0;
	x->gradientRect.y = 0;
	// horizontal mode
	if (x->effectOrientation) {
		x->gradientRect.width = box->b_patching_rect.width * 0.96;
		x->gradientRect.height = box->b_patching_rect.height;
	}
	// vertical mode
	else {
		x->gradientRect.width = box->b_patching_rect.width;
		x->gradientRect.height = box->b_patching_rect.height * 0.96;
	}

	if (x->gradientSurface)
		jgraphics_surface_destroy(x->gradientSurface);
	
	x->gradientSurface = jgraphics_image_surface_create(JGRAPHICS_FORMAT_ARGB32, x->gradientRect.width, x->gradientRect.height);
	
	color.red = 0.0;
	color.green = 1.0;
	color.blue = 0.0;
	color.alpha = 1.0;

	// horizontal mode
	if (x->effectOrientation) {
		for (i=0; i < x->gradientRect.width; i++) {
			color.red = i / x->gradientRect.width;	
			for (j=0; j < x->gradientRect.height; j++)
				jgraphics_image_surface_set_pixel(x->gradientSurface, i, j, color);
		}
	}
	else {
		for (j=0; j < x->gradientRect.height; j++) {
			color.red = 1. - (j / x->gradientRect.height);	
			for (i=0; i < x->gradientRect.width; i++)
				jgraphics_image_surface_set_pixel(x->gradientSurface, i, j, color);
		}
	}
}
void jucebox_paint(t_jucebox* x, t_object *patcherview)
{
    t_rect rect, srcRect, destRect;
    int width, height, imgStride;
    unsigned char* data;
    
    if(x->j_component->isOnDesktop())
    {
        x->j_component->setActive();
        if(x->j_component->isContextOk())
        {
            jbox_get_rect_for_view((t_object *)x, patcherview, &rect);
            t_jgraphics *g = (t_jgraphics *)patcherview_get_jgraphics(patcherview);
            if(g)
            {
                juce::Image openGLSnap = x->j_component->makeScreenshot((t_object *)x, rect.width, rect.height);
               
                juce::Image::BitmapData* snapBitmap = new juce::Image::BitmapData(openGLSnap, juce::Image::BitmapData::readOnly);
                data = snapBitmap->data;
                width = openGLSnap.getWidth();
                height = openGLSnap.getHeight();
                imgStride = snapBitmap->lineStride;
                
                srcRect.x = 0;
                destRect.x = 0;
                srcRect.y = 0;
                destRect.y = 0;
                srcRect.width = openGLSnap.getWidth();
                srcRect.height = openGLSnap.getHeight();
                destRect.width = rect.width;
                destRect.height = rect.height;
                
                t_jsurface* surface = jgraphics_image_surface_create_for_data(data, JGRAPHICS_FORMAT_ARGB32, width, height, imgStride, NULL, NULL);
                jgraphics_image_surface_draw(g, surface, srcRect, destRect);
                jgraphics_surface_destroy(surface);
            }
        }
        
    }
}