Ejemplo n.º 1
0
/*****************************************************
**
**   PdfPainter   ---   setBrush
**
******************************************************/
void PdfPainter::setBrush( const wxBrush &b )
{
	// TODO howto scale width und height 
	if ( b.GetStyle() == wxSTIPPLE )
	{
		wxImage image;
		wxBitmap *bitmap = b.GetStipple();
		if ( bitmap && bitmap->IsOk())
		{
			image = bitmap->ConvertToImage();

			double width = image.GetWidth() / 3;
			double height = image.GetHeight() / 3;

			// setup a hash value for the image
			wxString s = createImageHash( &image );

			pdf->AddPattern( s, image, width, height );
			drawmode = wxPDF_STYLE_FILL;
			pdf->SetFillPattern( s );
			pdf->SetDrawPattern( s );
		}
	}
	else if ( b.GetStyle() != wxTRANSPARENT && b.GetColour().IsOk() ) setBrushColor( b.GetColour() );
	else
	{
		drawmode = wxPDF_STYLE_DRAW;
	}
}
Ejemplo n.º 2
0
/*****************************************************
**
**   PdfPainter   ---   setBrush
**
******************************************************/
void PdfPainter::setBrush( const MBrush &b )
{
	// TODO howto scale width und height 
	if ( b.style == wxSOLID )
	{
		if ( b.color.IsOk() )
		{
			drawmode = wxPDF_STYLE_FILL;
			pdf->SetFillColour( b.color );
		}
		else wxLogError( wxT( "bitmap in PdfPainter::setBrush is not transparent but color is not okay" ));
	}
	else if ( b.style == wxSTIPPLE )
	{
		wxImage image;
		//wxBitmap *bitmap = b.GetStipple();
		wxBitmap bitmap = ImageProvider::get()->getFileBasedBitmap( b.filename, b.rotateHue );
		if ( bitmap.IsOk())
		{
			image = bitmap.ConvertToImage();

			double width = image.GetWidth() / 3;
			double height = image.GetHeight() / 3;

			// setup a hash value for the image
			wxString s = createImageHash( &image );

			pdf->AddPattern( s, image, width, height );
			drawmode = wxPDF_STYLE_FILL;
			pdf->SetFillPattern( s );
			pdf->SetDrawPattern( s );
		}
		else wxLogError( wxT( "bitmap in PdfPainter::setBrush not okay" ));
	}
	else if ( b.style != wxTRANSPARENT )
	{
		// TODO SetFillPattern( wxString name )
		if ( b.color.IsOk() )
		{
			drawmode = wxPDF_STYLE_FILL;
			pdf->SetFillColour( b.color );
		}
		else wxLogError( wxT( "bitmap in PdfPainter::setBrush is not transparent but color is not okay" ));
		//setBrush( b.GetColour() );
	}
	else // must be transparent
	{
		drawmode = wxPDF_STYLE_DRAW;
	}
}