25#include <wx/mstream.h>
36 if( !leftImage || !rightImage )
37 return leftImage == rightImage;
39 wxMemoryOutputStream leftStream;
40 wxMemoryOutputStream rightStream;
45 size_t leftSize = leftStream.GetSize();
46 size_t rightSize = rightStream.GetSize();
48 if( leftSize != rightSize )
54 std::string leftData( leftSize,
'\0' );
55 std::string rightData( rightSize,
'\0' );
57 leftStream.CopyTo( leftData.data(), leftSize );
58 rightStream.CopyTo( rightData.data(), rightSize );
60 return leftData == rightData;
138 double similarity = 1.0;
205 const double ratio = aWidth / (double)
m_bitmapBase->GetSize().x;
215 const double ratio = aHeight / (double)
m_bitmapBase->GetSize().y;
243 const VECTOR2D newCenter = currentOrigin - newOffset;
267 MIRROR( newPos, aCentre, aFlipDirection );
288 for(
double ang = 45.0; ang < norm.
AsDegrees(); ang += 90.0 )
331 wxMemoryOutputStream imageStream;
335 size_t size = imageStream.GetSize();
339 aOutputBytes.resize( size );
340 imageStream.CopyTo( aOutputBytes.data(), size );
348 if( aInputBytes.empty() )
351 wxMemoryBuffer imageBuffer;
352 imageBuffer.AppendData( aInputBytes.data(), aInputBytes.size() );
constexpr bool IsBOX2Safe(const BOX2< Vec > &aInput)
Check if a BOX2 is safe for use with BOX2D (probably BOX2D or BOX2L)
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
This class handle bitmap images in KiCad.
bool SaveImageData(wxOutputStream &aOutStream) const
Write the bitmap data to aOutStream.
static constexpr BOX2< VECTOR2I > ByCenter(const VECTOR2I &aCenter, const SizeVec &aSize)
BITMAP_BASE & MutableImage() const
Only use this if you really need to modify the underlying image.
const EDA_IU_SCALE & m_iuScale
void SwapData(REFERENCE_IMAGE &aItem)
VECTOR2I m_pos
XY coordinates of center of the bitmap.
void Rotate(const VECTOR2I &aCenter, const EDA_ANGLE &aAngle)
void SetTransformOriginOffset(const VECTOR2I &aCenter)
bool ReadImageFile(const wxString &aFullFilename)
Read and store an image file.
VECTOR2I GetTransformOriginOffset() const
Get the center of scaling, etc, relative to the image center (GetPosition()).
VECTOR2I GetPosition() const
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
bool SetImage(const wxImage &aImage)
Set the image from an existing wxImage.
std::unique_ptr< BITMAP_BASE > m_bitmapBase
REFERENCE_IMAGE & operator=(const REFERENCE_IMAGE &aOther)
void SetHeight(int aHeight)
VECTOR2I m_transformOriginOffset
Center of scaling, etc, relative to the image center.
bool UnpackFromBytes(const std::string &aInputBytes)
void SetPosition(const VECTOR2I &aPos)
void SetWidth(int aWidth)
void updatePixelSizeInIU()
const BITMAP_BASE & GetImage() const
Get the underlying image.
double Similarity(const REFERENCE_IMAGE &aOther) const
double GetImageScale() const
void SetImageScale(double aScale)
Set the image "zoom" value.
REFERENCE_IMAGE(const EDA_IU_SCALE &aIuScale)
BOX2I GetBoundingBox() const
void scaleBy(double ratio)
void PackToBytes(std::string &aOutputBytes) const
bool operator==(const REFERENCE_IMAGE &aOther) const
a few functions useful in geometry calculations.
bool IsVec2SafeXY(const VECTOR2< T > &aVec)
Check if both coordinates of a vector are within the limits of the integer type.
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
static bool compareImages(const BITMAP_BASE &aLeft, const BITMAP_BASE &aRight)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D