33#include <wx/mstream.h> 
   36#include <wx/wfstream.h>   
  102        if( 
m_originalImage->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONUNIT ) == wxIMAGE_RESOLUTION_CM )
 
 
  130    size_t dataSize = aInStream.GetLength();
 
  135    std::unique_ptr<wxImage> new_image = std::make_unique<wxImage>();
 
  138    wxMemoryInputStream mem_stream( 
m_imageData.GetData(), dataSize );
 
  139    if( !new_image->LoadFile( mem_stream ) )
 
 
  151    std::unique_ptr<wxImage> new_image = std::make_unique<wxImage>();
 
  156    if( !new_image->LoadFile( mem_stream ) )
 
 
  165    wxFileInputStream file_stream(aFullFilename);
 
  168    if (!file_stream.IsOk())
 
 
  177    if( !aImage.IsOk() || aImage.GetWidth() == 0 || aImage.GetHeight() == 0 )
 
  181    m_image = 
new wxImage( aImage );
 
 
  200        wxBitmapType type = 
m_imageType == wxBITMAP_TYPE_JPEG ? wxBITMAP_TYPE_JPEG
 
  203        if( !
m_image->SaveFile( aOutStream, type ) )
 
 
  220    wxMemoryOutputStream stream;
 
  227            aErrorMsg = wxT( 
"Unexpected end of data" );
 
  233        if( strncasecmp( line, 
"EndData", 4 ) == 0 )
 
  238            wxMemoryInputStream istream( stream );
 
  239            m_image->LoadFile( istream, wxBITMAP_TYPE_ANY );
 
  249        int len = strlen( line );
 
  251        for( ; len > 0; len -= 3, line += 3 )
 
  255            if( sscanf( line, 
"%X", &value ) == 1 )
 
  256                stream.PutC( (
char) value );
 
 
  287    if( ( size.
x == 0 ) || ( size.
y == 0 ) )
 
  295    int    logicalOriginX, logicalOriginY;
 
  297    aDC->GetLogicalOrigin( &logicalOriginX, &logicalOriginY );
 
  304    bool useTransform = aDC->CanUseTransformMatrix();
 
  306    wxAffineMatrix2D init_matrix = aDC->GetTransformMatrix();
 
  320        wxAffineMatrix2D matrix = aDC->GetTransformMatrix();
 
  321        matrix.Translate( pos.
x, pos.
y );
 
  323        aDC->SetTransformMatrix( matrix );
 
  328        clipAreaPos.x = pos.
x;
 
  329        clipAreaPos.y = pos.
y;
 
  343        clipAreaPos.x = pos.
x;
 
  344        clipAreaPos.y = pos.
y;
 
  348    aDC->DestroyClippingRegion();
 
  349    aDC->SetClippingRegion( clipAreaPos, wxSize( size.
x, size.
y ) );
 
  360        wxImage  
image( w, h );
 
  361        wxColour bgColor = aBackgroundColor.
ToColour();
 
  363        image.SetRGB( wxRect( 0, 0, w, h ), bgColor.Red(), bgColor.Green(), bgColor.Blue() );
 
  364        image.Paste( 
m_bitmap->ConvertToImage(), 0, 0, wxIMAGE_ALPHA_BLEND_COMPOSE );
 
  369        aDC->DrawBitmap( wxBitmap( 
image ), pos.
x, pos.
y, 
true );
 
  373        wxBitmap 
result( 
m_bitmap->ConvertToImage().ConvertToGreyscale() );
 
  374        aDC->DrawBitmap( 
result, pos.
x, pos.
y, 
true );
 
  378        aDC->DrawBitmap( *
m_bitmap, pos.
x, pos.
y, 
true );
 
  382        aDC->SetTransformMatrix( init_matrix );
 
  386        aDC->SetLogicalOrigin( logicalOriginX, logicalOriginY );
 
  390    aDC->DestroyClippingRegion();
 
 
  420        int resX = 
m_image->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONX );
 
  421        int resY = 
m_image->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONY );
 
  422        int unit = 
m_image->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONUNIT );
 
  426        m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONUNIT , unit);
 
  427        m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONX, resX);
 
  428        m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONY, resY);
 
 
  449        int resX = 
m_image->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONX );
 
  450        int resY = 
m_image->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONY );
 
  451        int unit = 
m_image->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONUNIT );
 
  455        m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONUNIT, unit );
 
  456        m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONX, resX );
 
  457        m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONY, resY );
 
 
  480                             int            aDefaultPensize )
 const 
  487    aPlotter->
SetColor( aDefaultColor );
 
 
  497        wxMemoryOutputStream stream;
 
  498        wxBitmapType type = 
m_imageType == wxBITMAP_TYPE_JPEG ? wxBITMAP_TYPE_JPEG
 
  501        if( !
m_image->SaveFile( stream, type ) )
 
  505        stream.CopyTo( 
m_imageData.GetData(), stream.GetLength() );
 
 
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
 
wxMemoryBuffer m_imageData
The original image data in its original format.
 
void Rotate(bool aRotateCCW)
Rotate image CW or CCW.
 
bool LoadLegacyData(LINE_READER &aLine, wxString &aErrorMsg)
Load an image data saved by #SaveData.
 
void updateImageDataBuffer()
Resets the image data buffer using the current image data.
 
double GetScalingFactor() const
This scaling factor depends on m_pixelSizeIu and m_scale.
 
void PlotImage(PLOTTER *aPlotter, const VECTOR2I &aPos, const KIGFX::COLOR4D &aDefaultColor, int aDefaultPensize) const
Plot bitmap on plotter.
 
void Mirror(FLIP_DIRECTION aFlipDirection)
Mirror image vertically (i.e.
 
const BOX2I GetBoundingBox() const
Return the orthogonal, bounding box of this object for display purposes.
 
void ImportData(BITMAP_BASE &aItem)
Copy aItem image to this object and update m_bitmap.
 
bool SaveImageData(wxOutputStream &aOutStream) const
Write the bitmap data to aOutStream.
 
wxImage * m_originalImage
Raw image data, not transformed by rotate/mirror.
 
void rebuildBitmap(bool aResetID=true)
Rebuild the internal bitmap used to draw/plot image.
 
wxBitmapType m_imageType
The image type (png, jpeg, etc.).
 
wxBitmap * m_bitmap
The bitmap used to draw/plot image.
 
void ConvertToGreyscale()
 
bool SetImage(const wxImage &aImage)
Set the image from an existing wxImage.
 
bool ReadImageFile(const wxString &aFullFilename)
Reads and stores in memory an image file.
 
wxImage * m_image
The raw, uncompressed image data.
 
double m_scale
The scaling factor of the bitmap with m_pixelSizeIu, controls the actual draw size.
 
double m_pixelSizeIu
The scaling factor of the bitmap to convert the bitmap size (in pixels) to internal KiCad units.
 
int m_ppi
The bitmap definition. The default is 300PPI.
 
void DrawBitmap(wxDC *aDC, const VECTOR2I &aPos, const KIGFX::COLOR4D &aBackgroundColor=KIGFX::COLOR4D::UNSPECIFIED) const
 
BITMAP_BASE(const VECTOR2I &pos=VECTOR2I(0, 0))
 
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
 
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
 
A color representation with 4 components: red, green, blue, alpha.
 
wxColour ToColour() const
 
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
 
virtual char * ReadLine()=0
Read a line of text into the buffer and increments the line number counter.
 
char * Line() const
Return a pointer to the last line that was read in.
 
Base plotter engine class.
 
virtual void PlotImage(const wxImage &aImage, const VECTOR2I &aPos, double aScaleFactor)
Only PostScript plotters can plot bitmaps.
 
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
 
virtual void SetColor(const COLOR4D &color)=0
 
static constexpr EDA_ANGLE ANGLE_0
 
static constexpr EDA_ANGLE ANGLE_90
 
bool GetGRForceBlackPenState(void)
 
@ LEFT_RIGHT
Flip left to right (around the Y axis)
 
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
 
wxString result
Test unit parsing edge cases and error handling.
 
VECTOR2< int32_t > VECTOR2I