KiCad PCB EDA Suite
|
This class handle bitmap images in KiCad. More...
#include <bitmap_base.h>
Public Member Functions | |
BITMAP_BASE (const VECTOR2I &pos=VECTOR2I(0, 0)) | |
BITMAP_BASE (const BITMAP_BASE &aSchBitmap) | |
~BITMAP_BASE () | |
double | GetPixelSizeIu () const |
void | SetPixelSizeIu (double aPixSize) |
wxImage * | GetImageData () |
const wxImage * | GetImageData () const |
const wxImage * | GetOriginalImageData () const |
double | GetScale () const |
void | SetScale (double aScale) |
KIID | GetImageID () const |
void | ImportData (BITMAP_BASE *aItem) |
Copy aItem image to this object and update m_bitmap. More... | |
double | GetScalingFactor () const |
This scaling factor depends on m_pixelSizeIu and m_scale. More... | |
VECTOR2I | GetSize () const |
VECTOR2I | GetSizePixels () const |
int | GetPPI () const |
const BOX2I | GetBoundingBox () const |
Return the orthogonal, bounding box of this object for display purposes. More... | |
void | DrawBitmap (wxDC *aDC, const VECTOR2I &aPos, const KIGFX::COLOR4D &aBackgroundColor=KIGFX::COLOR4D::UNSPECIFIED) |
bool | ReadImageFile (const wxString &aFullFilename) |
Reads and stores in memory an image file. More... | |
bool | ReadImageFile (wxInputStream &aInStream) |
Reads and stores in memory an image file. More... | |
bool | ReadImageFile (wxMemoryBuffer &aBuf) |
Reads and stores in memory an image file. More... | |
bool | SaveImageData (wxOutputStream &aOutStream) const |
Write the bitmap data to aOutStream. More... | |
bool | LoadLegacyData (LINE_READER &aLine, wxString &aErrorMsg) |
Load an image data saved by #SaveData. More... | |
void | Mirror (bool aVertically) |
Mirror image vertically (i.e. More... | |
void | Rotate (bool aRotateCCW) |
Rotate image CW or CCW. More... | |
void | ConvertToGreyscale () |
bool | IsMirroredX () const |
bool | IsMirroredY () const |
EDA_ANGLE | Rotation () const |
void | PlotImage (PLOTTER *aPlotter, const VECTOR2I &aPos, const KIGFX::COLOR4D &aDefaultColor, int aDefaultPensize) const |
Plot bitmap on plotter. More... | |
wxBitmapType | GetImageType () const |
Return the bitmap type (png, jpeg, etc.) More... | |
void | SetImageType (wxBitmapType aType) |
Set the bitmap type (png, jpeg, etc.) More... | |
const wxMemoryBuffer & | GetImageDataBuffer () const |
void | UpdateImageDataBuffer () |
Resets the image data buffer using the current image data. More... | |
Private Member Functions | |
void | rebuildBitmap (bool aResetID=true) |
void | updatePPI () |
Private Attributes | |
double | m_scale |
wxMemoryBuffer | m_imageData |
wxBitmapType | m_imageType |
wxImage * | m_image |
wxImage * | m_originalImage |
wxBitmap * | m_bitmap |
double | m_pixelSizeIu |
int | m_ppi |
KIID | m_imageId |
bool | m_isMirroredX |
bool | m_isMirroredY |
EDA_ANGLE | m_rotation |
This class handle bitmap images in KiCad.
It is not intended to be used alone, but inside another class so all methods are protected or private. It is used in SCH_BITMAP class, DS_DRAW_ITEM_BITMAP, and possibly others in the future.
Definition at line 47 of file bitmap_base.h.
Definition at line 39 of file bitmap_base.cpp.
References ANGLE_0, m_bitmap, m_image, m_imageType, m_isMirroredX, m_isMirroredY, m_originalImage, m_pixelSizeIu, m_ppi, m_rotation, and m_scale.
BITMAP_BASE::BITMAP_BASE | ( | const BITMAP_BASE & | aSchBitmap | ) |
Definition at line 55 of file bitmap_base.cpp.
References m_bitmap, m_image, m_imageData, m_imageId, m_imageType, m_isMirroredX, m_isMirroredY, m_originalImage, m_pixelSizeIu, m_ppi, m_rotation, and m_scale.
|
inline |
Definition at line 54 of file bitmap_base.h.
References m_bitmap, m_image, and m_originalImage.
void BITMAP_BASE::ConvertToGreyscale | ( | ) |
Definition at line 464 of file bitmap_base.cpp.
References m_image, m_originalImage, rebuildBitmap(), and UpdateImageDataBuffer().
Referenced by PANEL_IMAGE_EDITOR::OnGreyScaleConvert().
void BITMAP_BASE::DrawBitmap | ( | wxDC * | aDC, |
const VECTOR2I & | aPos, | ||
const KIGFX::COLOR4D & | aBackgroundColor = KIGFX::COLOR4D::UNSPECIFIED |
||
) |
Definition at line 276 of file bitmap_base.cpp.
References GetGRForceBlackPenState(), GetScalingFactor(), GetSize(), image, KiROUND(), m_bitmap, scale, KIGFX::COLOR4D::ToColour(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by PANEL_IMAGE_EDITOR::OnRedrawPanel(), SCH_BITMAP::Print(), and DS_DRAW_ITEM_BITMAP::PrintWsItem().
const BOX2I BITMAP_BASE::GetBoundingBox | ( | ) | const |
Return the orthogonal, bounding box of this object for display purposes.
This box should be an enclosing perimeter for visible components of this object, and the units should be in the pcb or schematic coordinate system. It is OK to overestimate the size by a few counts.
Definition at line 265 of file bitmap_base.cpp.
References GetSize(), BOX2< Vec >::Inflate(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BOOST_AUTO_TEST_CASE(), and SCH_BITMAP::GetBoundingBox().
|
inline |
Definition at line 67 of file bitmap_base.h.
References m_image.
Referenced by BOOST_AUTO_TEST_CASE(), KIGFX::CAIRO_GAL_BASE::DrawBitmap(), PCB_PLUGIN::format(), SCH_LEGACY_PLUGIN::saveBitmap(), and SCH_SEXPR_PLUGIN::saveBitmap().
|
inline |
Definition at line 68 of file bitmap_base.h.
References m_image.
|
inline |
Definition at line 240 of file bitmap_base.h.
References m_imageData.
Referenced by PCB_PLUGIN::format(), DS_DATA_MODEL_IO::format(), and SCH_SEXPR_PLUGIN::saveBitmap().
|
inline |
Definition at line 75 of file bitmap_base.h.
References m_imageId.
Referenced by KIGFX::GL_BITMAP_CACHE::cacheBitmap(), and KIGFX::GL_BITMAP_CACHE::RequestBitmap().
|
inline |
Return the bitmap type (png, jpeg, etc.)
Definition at line 230 of file bitmap_base.h.
References m_imageType.
|
inline |
Definition at line 70 of file bitmap_base.h.
References m_originalImage.
Referenced by KIGFX::GL_BITMAP_CACHE::cacheBitmap(), DS_DATA_MODEL_IO::format(), and DS_DATA_ITEM_BITMAP::SyncDrawItems().
|
inline |
Definition at line 64 of file bitmap_base.h.
References m_pixelSizeIu.
Referenced by BOOST_AUTO_TEST_CASE().
|
inline |
Definition at line 117 of file bitmap_base.h.
References m_ppi.
Referenced by BOOST_AUTO_TEST_CASE(), KIGFX::CAIRO_GAL_BASE::DrawBitmap(), KIGFX::OPENGL_GAL::DrawBitmap(), DS_DATA_ITEM_BITMAP::GetPPI(), SCH_LEGACY_PLUGIN::loadBitmap(), PCB_BITMAP::operator=(), PANEL_IMAGE_EDITOR::PANEL_IMAGE_EDITOR(), PCB_BITMAP::PCB_BITMAP(), PL_EDITOR_FRAME::PrintPage(), PLEDITOR_PRINTOUT::PrintPage(), SCH_BITMAP::ReadImageFile(), PCB_BITMAP::ReadImageFile(), SCH_SEXPR_PLUGIN::saveBitmap(), SCH_BITMAP::SCH_BITMAP(), DS_DATA_ITEM_BITMAP::SetPPI(), and DS_DATA_ITEM_BITMAP::SyncDrawItems().
|
inline |
Definition at line 72 of file bitmap_base.h.
References m_scale.
Referenced by BOOST_AUTO_TEST_CASE(), PCB_PLUGIN::format(), DS_DATA_MODEL_IO::format(), SCH_BITMAP::GetImageScale(), PCB_BITMAP::GetImageScale(), DS_DATA_ITEM_BITMAP::GetPPI(), SCH_LEGACY_PLUGIN::loadBitmap(), PANEL_IMAGE_EDITOR::PANEL_IMAGE_EDITOR(), SCH_LEGACY_PLUGIN::saveBitmap(), and SCH_SEXPR_PLUGIN::saveBitmap().
|
inline |
This scaling factor depends on m_pixelSizeIu and m_scale.
m_pixelSizeIu gives the scaling factor between a pixel size and the internal units. m_scale is an user dependent value, and gives the "zoom" value.
Definition at line 93 of file bitmap_base.h.
References m_pixelSizeIu, and m_scale.
Referenced by DrawBitmap(), GetSize(), PANEL_IMAGE_EDITOR::OnRedrawPanel(), and PlotImage().
VECTOR2I BITMAP_BASE::GetSize | ( | ) | const |
Definition at line 393 of file bitmap_base.cpp.
References GetScalingFactor(), KiROUND(), m_bitmap, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BOOST_AUTO_TEST_CASE(), DrawBitmap(), GetBoundingBox(), DS_DRAW_ITEM_BITMAP::GetBoundingBox(), PCB_BITMAP::GetBoundingBox(), SCH_BITMAP::GetSize(), PCB_BITMAP::GetSize(), and PANEL_IMAGE_EDITOR::OnRedrawPanel().
|
inline |
Definition at line 106 of file bitmap_base.h.
References m_image.
Referenced by BOOST_AUTO_TEST_CASE(), PANEL_IMAGE_EDITOR::CheckValues(), KIGFX::CAIRO_GAL_BASE::DrawBitmap(), KIGFX::OPENGL_GAL::DrawBitmap(), and PANEL_IMAGE_EDITOR::OnRedrawPanel().
void BITMAP_BASE::ImportData | ( | BITMAP_BASE * | aItem | ) |
Copy aItem image to this object and update m_bitmap.
Definition at line 108 of file bitmap_base.cpp.
References m_bitmap, m_image, m_imageData, m_imageId, m_imageType, m_isMirroredX, m_isMirroredY, m_originalImage, m_pixelSizeIu, m_ppi, m_rotation, and m_scale.
Referenced by PANEL_IMAGE_EDITOR::TransferToImage().
|
inline |
Definition at line 210 of file bitmap_base.h.
References m_isMirroredX.
Referenced by KIGFX::OPENGL_GAL::DrawBitmap().
|
inline |
Definition at line 211 of file bitmap_base.h.
References m_isMirroredY.
Referenced by KIGFX::OPENGL_GAL::DrawBitmap().
bool BITMAP_BASE::LoadLegacyData | ( | LINE_READER & | aLine, |
wxString & | aErrorMsg | ||
) |
Load an image data saved by #SaveData.
The file format must be png format in hexadecimal.
aLine | the LINE_READER used to read the data file. |
aErrorMsg | Description of the error if an error occurs while loading the png bitmap data. |
Definition at line 217 of file bitmap_base.cpp.
References LINE_READER::Line(), m_bitmap, m_image, m_originalImage, LINE_READER::ReadLine(), and UpdateImageDataBuffer().
Referenced by DRAWING_SHEET_PARSER::readPngdata().
void BITMAP_BASE::Mirror | ( | bool | aVertically | ) |
Mirror image vertically (i.e.
relative to its horizontal X axis ) or horizontally (i.e relative to its vertical Y axis).
aVertically | false to mirror horizontally or true to mirror vertically. |
Definition at line 410 of file bitmap_base.cpp.
References m_image, m_isMirroredX, m_isMirroredY, rebuildBitmap(), and UpdateImageDataBuffer().
Referenced by PCB_BITMAP::Flip(), SCH_BITMAP::MirrorHorizontally(), and SCH_BITMAP::MirrorVertically().
void BITMAP_BASE::PlotImage | ( | PLOTTER * | aPlotter, |
const VECTOR2I & | aPos, | ||
const KIGFX::COLOR4D & | aDefaultColor, | ||
int | aDefaultPensize | ||
) | const |
Plot bitmap on plotter.
If the plotter does not support bitmaps, plot a
aPlotter | the plotter to use. |
aPos | the position of the center of the bitmap. |
aDefaultColor | the color used to plot the rectangle when bitmap is not supported. |
aDefaultPensize | the pen size used to plot the rectangle when bitmap is not supported. |
Definition at line 476 of file bitmap_base.cpp.
References GetScalingFactor(), m_image, PLOTTER::PlotImage(), PLOTTER::SetColor(), and PLOTTER::SetCurrentLineWidth().
Referenced by SCH_BITMAP::Plot(), and PlotDrawingSheet().
bool BITMAP_BASE::ReadImageFile | ( | const wxString & | aFullFilename | ) |
Reads and stores in memory an image file.
Initialize the bitmap format used to draw this item. Supported images formats are format supported by wxImage if all handlers are loaded. By default, .png, .jpeg are always loaded.
aFullFilename | The full filename of the image file to read. |
Definition at line 183 of file bitmap_base.cpp.
References ReadImageFile().
Referenced by DRAWING_SHEET_PARSER::parseBitmap(), SCH_BITMAP::ReadImageFile(), ReadImageFile(), PCB_BITMAP::ReadImageFile(), and TEST_BITMAP_BASE_FIXTURE::TEST_BITMAP_BASE_FIXTURE().
bool BITMAP_BASE::ReadImageFile | ( | wxInputStream & | aInStream | ) |
Reads and stores in memory an image file.
Initialize the bitmap format used to draw this item.
Supported images formats are format supported by wxImage if all handlers are loaded. By default, .png, .jpeg are always loaded.
aInStream | an input stream containing the file data. |
Definition at line 125 of file bitmap_base.cpp.
References m_image, m_imageData, m_imageType, m_originalImage, rebuildBitmap(), and updatePPI().
bool BITMAP_BASE::ReadImageFile | ( | wxMemoryBuffer & | aBuf | ) |
Reads and stores in memory an image file.
Initialize the bitmap format used to draw this item.
Supported images formats are format supported by wxImage if all handlers are loaded. By default, .png, .jpeg are always loaded.
aBuf | a memory buffer containing the file data. |
Definition at line 155 of file bitmap_base.cpp.
References m_image, m_imageData, m_imageType, m_originalImage, rebuildBitmap(), and updatePPI().
|
private |
Definition at line 80 of file bitmap_base.cpp.
References m_bitmap, m_image, and m_imageId.
Referenced by ConvertToGreyscale(), Mirror(), ReadImageFile(), and Rotate().
void BITMAP_BASE::Rotate | ( | bool | aRotateCCW | ) |
Rotate image CW or CCW.
aRotateCCW | true to rotate CCW or false to rotate CW. |
Definition at line 439 of file bitmap_base.cpp.
References ANGLE_90, m_image, m_rotation, rebuildBitmap(), and UpdateImageDataBuffer().
Referenced by SCH_BITMAP::Rotate(), and PCB_BITMAP::Rotate().
|
inline |
Definition at line 212 of file bitmap_base.h.
References m_rotation.
Referenced by KIGFX::OPENGL_GAL::DrawBitmap().
bool BITMAP_BASE::SaveImageData | ( | wxOutputStream & | aOutStream | ) | const |
Write the bitmap data to aOutStream.
This writes binary data, not hexadecimal strings
aOutStream | The output stream to write to. |
Definition at line 195 of file bitmap_base.cpp.
References m_image, m_imageData, and m_imageType.
|
inline |
Set the bitmap type (png, jpeg, etc.)
Definition at line 235 of file bitmap_base.h.
References m_imageType.
|
inline |
Definition at line 65 of file bitmap_base.h.
References m_pixelSizeIu.
Referenced by PCB_BITMAP::operator=(), PCB_BITMAP::PCB_BITMAP(), PL_EDITOR_FRAME::PrintPage(), PLEDITOR_PRINTOUT::PrintPage(), SCH_BITMAP::ReadImageFile(), PCB_BITMAP::ReadImageFile(), SCH_BITMAP::SCH_BITMAP(), DS_DATA_ITEM_BITMAP::SyncDrawItems(), and TEST_BITMAP_BASE_FIXTURE::TEST_BITMAP_BASE_FIXTURE().
|
inline |
Definition at line 73 of file bitmap_base.h.
References m_scale.
Referenced by SCH_LEGACY_PLUGIN::loadBitmap(), DRAWING_SHEET_PARSER::parseBitmap(), SCH_BITMAP::SetImageScale(), PCB_BITMAP::SetImageScale(), DS_DATA_ITEM_BITMAP::SetPPI(), TEST_BITMAP_BASE_FIXTURE::TEST_BITMAP_BASE_FIXTURE(), and PANEL_IMAGE_EDITOR::TransferToImage().
void BITMAP_BASE::UpdateImageDataBuffer | ( | ) |
Resets the image data buffer using the current image data.
Definition at line 491 of file bitmap_base.cpp.
References m_image, m_imageData, and m_imageType.
Referenced by ConvertToGreyscale(), LoadLegacyData(), Mirror(), and Rotate().
|
private |
Definition at line 93 of file bitmap_base.cpp.
References KiROUND(), m_originalImage, and m_ppi.
Referenced by ReadImageFile().
|
private |
Definition at line 266 of file bitmap_base.h.
Referenced by BITMAP_BASE(), DrawBitmap(), GetSize(), ImportData(), LoadLegacyData(), rebuildBitmap(), and ~BITMAP_BASE().
|
private |
Definition at line 264 of file bitmap_base.h.
Referenced by BITMAP_BASE(), ConvertToGreyscale(), GetImageData(), GetSizePixels(), ImportData(), LoadLegacyData(), Mirror(), PlotImage(), ReadImageFile(), rebuildBitmap(), Rotate(), SaveImageData(), UpdateImageDataBuffer(), and ~BITMAP_BASE().
|
private |
Definition at line 261 of file bitmap_base.h.
Referenced by BITMAP_BASE(), GetImageDataBuffer(), ImportData(), ReadImageFile(), SaveImageData(), and UpdateImageDataBuffer().
|
private |
Definition at line 272 of file bitmap_base.h.
Referenced by BITMAP_BASE(), GetImageID(), ImportData(), and rebuildBitmap().
|
private |
Definition at line 262 of file bitmap_base.h.
Referenced by BITMAP_BASE(), GetImageType(), ImportData(), ReadImageFile(), SaveImageData(), SetImageType(), and UpdateImageDataBuffer().
|
private |
Definition at line 273 of file bitmap_base.h.
Referenced by BITMAP_BASE(), ImportData(), IsMirroredX(), and Mirror().
|
private |
Definition at line 274 of file bitmap_base.h.
Referenced by BITMAP_BASE(), ImportData(), IsMirroredY(), and Mirror().
|
private |
Definition at line 265 of file bitmap_base.h.
Referenced by BITMAP_BASE(), ConvertToGreyscale(), GetOriginalImageData(), ImportData(), LoadLegacyData(), ReadImageFile(), updatePPI(), and ~BITMAP_BASE().
|
private |
Definition at line 267 of file bitmap_base.h.
Referenced by BITMAP_BASE(), GetPixelSizeIu(), GetScalingFactor(), ImportData(), and SetPixelSizeIu().
|
private |
Definition at line 271 of file bitmap_base.h.
Referenced by BITMAP_BASE(), GetPPI(), ImportData(), and updatePPI().
|
private |
Definition at line 275 of file bitmap_base.h.
Referenced by BITMAP_BASE(), ImportData(), Rotate(), and Rotation().
|
private |
Definition at line 259 of file bitmap_base.h.
Referenced by BITMAP_BASE(), GetScale(), GetScalingFactor(), ImportData(), and SetScale().