Beispiel #1
0
void
BitmapImage::PixmapComplete ()
{
	MoonPixbuf *pixbuf;
	
	SetProgress (1.0);

	if (!loader) {
		if (!moon_error)
			moon_error = new MoonError (MoonError::EXCEPTION, 4001, "no loader");
		goto failed;
	}

	loader->Close (moon_error == NULL ? &moon_error : NULL);

	if (moon_error)
		goto failed;

	if (!(pixbuf = loader->GetPixbuf ())) {
		moon_error = new MoonError (MoonError::EXCEPTION, 4001, "failed to create image data");
		goto failed;
	}
	
	SetPixelWidth (pixbuf->GetWidth ());
	SetPixelHeight (pixbuf->GetHeight ());
	
	// PixelFormat has been dropped and only Pbgra32 is supported
	// http://blogs.msdn.com/silverlight_sdk/archive/2009/07/01/breaking-changes-document-errata-silverlight-3.aspx
	// not clear if '3' channel is still supported (converted to 4) in SL3
	if (pixbuf->GetNumChannels () == 4) {
		SetBitmapData (premultiply_rgba (pixbuf), true);
	} else {
		SetBitmapData (expand_rgb_to_argb (pixbuf), true);
	}
	
	Invalidate ();
	
	delete loader;
	loader = NULL;
	
	if (HasHandlers (ImageOpenedEvent))
		Emit (ImageOpenedEvent, new RoutedEventArgs ());
	
	return;
	
failed:
	ImageErrorEventArgs *args = NULL;

	if (HasHandlers (ImageFailedEvent))
		args = new ImageErrorEventArgs (*moon_error);
	CleanupLoader ();
	if (args)
		Emit (ImageFailedEvent, args);
}
Beispiel #2
0
void
BitmapSource::SetBitmapData (gpointer data, bool own_data)
{
	if (data == NULL) {
		SetPixelWidth (0.0);
		SetPixelHeight (0.0);
	}

	if (this->data && this->own_data)
		g_free (this->data);
	this->own_data = own_data;
	this->data = data;
}
Beispiel #3
0
void
BitmapImage::CleanupLoader ()
{
	SetPixelWidth (0);
	SetPixelHeight (0);

	if (loader) {
		loader->Close (NULL);
		delete loader;
		loader = NULL;
	}
	
	if (moon_error) {
		delete moon_error;
		moon_error = NULL;
	}
}
Beispiel #4
0
gpointer
WriteableBitmap::InitializeFromBitmapSource (BitmapSource *source)
{
	cairo_t *cr;

	if (!source)
		return NULL;

	SetPixelHeight (source->GetPixelHeight ());
	SetPixelWidth (source->GetPixelWidth ());

	image_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, GetPixelWidth (), GetPixelHeight ());
	cr = cairo_create (image_surface);
	cairo_set_source_surface (cr, source->GetImageSurface (), 0, 0);
	cairo_paint (cr);
	cairo_destroy (cr);

	SetBitmapData (cairo_image_surface_get_data (image_surface), false);

	return GetBitmapData ();
}
Beispiel #5
0
void CSvmDC::SetMapMode(TSvmMapMode & mapMode, bool prefered )
{
	m_oMapMode = mapMode;

	double dPixel = 1.;//
	switch (GetMapModeUnit())
	{
	case MAP_MM:	// 1 unit = 1 mm
	{
		dPixel = 1. * 72 / 25.4;
		SetPixelWidth(dPixel);
		SetPixelHeight(dPixel);		
	}break;
	case MAP_CM:	// 1 unit = 1 cm = 10 mm
	{
		dPixel = 10. * 72 / 25.4;
		SetPixelWidth(dPixel);
		SetPixelHeight(dPixel);		
	}break;
	case MAP_100TH_MM:
	{
		dPixel = 1. * 72 / 2540.;
		SetPixelWidth(dPixel);
		SetPixelHeight(dPixel);	
	}break;
	case MAP_10TH_MM:
	{
		dPixel = 1. * 72 / 254.;
		SetPixelWidth(dPixel);
		SetPixelHeight(dPixel);	
	}break;
	case MAP_1000TH_INCH:
	{	
		dPixel = 1. * 72 / 1000.;
		SetPixelWidth(dPixel);
		SetPixelHeight(dPixel);	
	}break;
	case MAP_100TH_INCH:
	{
		dPixel = 1.* 72 / 100.;
		SetPixelWidth(dPixel);
		SetPixelHeight(dPixel);	
	}break;
	case MAP_10TH_INCH:
	{
		dPixel = 1. * 72 / 10.;
		SetPixelWidth(dPixel);
		SetPixelHeight(dPixel);	
	}break;
	case MAP_INCH:	// 1 unit = 1 inch
	{
		dPixel = 1. * 72;
		SetPixelWidth(dPixel);
		SetPixelHeight(dPixel);		
	}break;
	case MAP_POINT:
	{
		SetPixelWidth(1);
		SetPixelHeight(1);		
	}break;
	case MAP_TWIP: // 1 unit = 1/1440 inch
	{
		SetPixelWidth(0.05);
		SetPixelHeight(0.05);		
	}break;
	case MAP_PIXEL:
	{
		dPixel = 0.5;// /72.; //todooo
		SetPixelWidth(dPixel);
		SetPixelHeight(dPixel);		
	}break;
	case MAP_SYSFONT:
	case MAP_APPFONT:
		//хз
		break;
	case MAP_RELATIVE:
		SetPixelWidth(dPixel);
		SetPixelHeight(dPixel);
		break;
	case MAP_LASTENUMDUMMY:
		break;
	}

	if (prefered )
	{
		m_dPixelHeightPrefered	= m_dPixelHeight;
		m_dPixelWidthPrefered	= m_dPixelWidth;
	}
}