![]() |
KiCad PCB EDA Suite
|
This class handle bitmap images in KiCad. More...
#include <bitmap_base.h>
Public Member Functions | |
BITMAP_BASE (const wxPoint &pos=wxPoint(0, 0)) | |
BITMAP_BASE (const BITMAP_BASE &aSchBitmap) | |
~BITMAP_BASE () | |
double | GetPixelSizeIu () const |
void | SetPixelSizeIu (double aPixSize) |
wxImage * | GetImageData () |
const wxImage * | GetImageData () const |
void | SetImage (wxImage *aImage) |
double | GetScale () const |
void | SetScale (double aScale) |
void | RebuildBitmap () |
void | SetBitmap (wxBitmap *aBitMap) |
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... | |
wxSize | GetSize () const |
wxSize | GetSizePixels () const |
int | GetPPI () const |
const EDA_RECT | GetBoundingBox () const |
Return the orthogonal, bounding box of this object for display purposes. More... | |
void | DrawBitmap (wxDC *aDC, const wxPoint &aPos) |
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 | SaveData (FILE *aFile) const |
Write the bitmap data to aFile. More... | |
void | SaveData (wxArrayString &aPngStrings) const |
Write the bitmap data to an array string. More... | |
bool | LoadData (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 | PlotImage (PLOTTER *aPlotter, const wxPoint &aPos, KIGFX::COLOR4D aDefaultColor, int aDefaultPensize) const |
Plot bitmap on plotter. More... | |
Private Attributes | |
double | m_scale |
wxImage * | m_image |
wxBitmap * | m_bitmap |
double | m_pixelSizeIu |
int | m_ppi |
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 51 of file bitmap_base.h.
BITMAP_BASE::BITMAP_BASE | ( | const wxPoint & | pos = wxPoint( 0, 0 ) | ) |
Definition at line 45 of file bitmap_base.cpp.
References m_bitmap, m_image, m_pixelSizeIu, m_ppi, m_scale, and NULL.
BITMAP_BASE::BITMAP_BASE | ( | const BITMAP_BASE & | aSchBitmap | ) |
Definition at line 56 of file bitmap_base.cpp.
References m_bitmap, m_image, m_pixelSizeIu, m_ppi, and m_scale.
|
inline |
Definition at line 58 of file bitmap_base.h.
void BITMAP_BASE::DrawBitmap | ( | wxDC * | aDC, |
const wxPoint & | aPos | ||
) |
Definition at line 241 of file bitmap_base.cpp.
References GetGRForceBlackPenState(), GetScalingFactor(), GetSize(), KiROUND(), m_bitmap, NULL, and scale.
Referenced by DIALOG_IMAGE_EDITOR::OnRedrawPanel(), SCH_BITMAP::Print(), and DS_DRAW_ITEM_BITMAP::PrintWsItem().
const EDA_RECT 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 229 of file bitmap_base.cpp.
References GetSize(), and EDA_RECT::Inflate().
Referenced by BOOST_AUTO_TEST_CASE(), and SCH_BITMAP::GetBoundingBox().
|
inline |
Definition at line 70 of file bitmap_base.h.
References m_image.
Referenced by BOOST_AUTO_TEST_CASE(), KIGFX::GL_BITMAP_CACHE::cacheBitmap(), KIGFX::CAIRO_GAL_BASE::DrawBitmap(), DIALOG_IMAGE_EDITOR::OnGreyScaleConvert(), SCH_SEXPR_PLUGIN::saveBitmap(), and SCH_LEGACY_PLUGIN::saveBitmap().
|
inline |
|
inline |
Definition at line 67 of file bitmap_base.h.
References m_pixelSizeIu.
Referenced by BOOST_AUTO_TEST_CASE().
|
inline |
Definition at line 135 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(), PLEDITOR_PRINTOUT::PrintPage(), PL_EDITOR_FRAME::PrintPage(), DS_DATA_ITEM_BITMAP::SetPPI(), and DS_DATA_ITEM_BITMAP::SyncDrawItems().
|
inline |
Definition at line 79 of file bitmap_base.h.
References m_scale.
Referenced by BOOST_AUTO_TEST_CASE(), DIALOG_IMAGE_EDITOR::DIALOG_IMAGE_EDITOR(), DS_DATA_MODEL_IO::format(), SCH_BITMAP::GetImageScale(), DS_DATA_ITEM_BITMAP::GetPPI(), SCH_SEXPR_PLUGIN::saveBitmap(), and SCH_LEGACY_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 111 of file bitmap_base.h.
References m_pixelSizeIu, and m_scale.
Referenced by DrawBitmap(), GetSize(), DIALOG_IMAGE_EDITOR::OnRedrawPanel(), and PlotImage().
wxSize BITMAP_BASE::GetSize | ( | ) | const |
Definition at line 303 of file bitmap_base.cpp.
References GetScalingFactor(), KiROUND(), and m_bitmap.
Referenced by BOOST_AUTO_TEST_CASE(), DrawBitmap(), GetBoundingBox(), and SCH_BITMAP::GetSize().
|
inline |
Definition at line 124 of file bitmap_base.h.
References m_image.
Referenced by BOOST_AUTO_TEST_CASE(), KIGFX::GL_BITMAP_CACHE::cacheBitmap(), DIALOG_IMAGE_EDITOR::CheckValues(), KIGFX::CAIRO_GAL_BASE::DrawBitmap(), and KIGFX::OPENGL_GAL::DrawBitmap().
void BITMAP_BASE::ImportData | ( | BITMAP_BASE * | aItem | ) |
Copy aItem image to this object and update m_bitmap.
Function ImportData Copy aItem image to me and update m_bitmap.
Definition at line 77 of file bitmap_base.cpp.
References m_bitmap, m_image, m_pixelSizeIu, m_ppi, and m_scale.
Referenced by DIALOG_IMAGE_EDITOR::TransferToImage().
bool BITMAP_BASE::LoadData | ( | 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 183 of file bitmap_base.cpp.
References LINE_READER::Line(), m_bitmap, m_image, and LINE_READER::ReadLine().
Referenced by DRAWING_SHEET_READER_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 320 of file bitmap_base.cpp.
References m_image, and RebuildBitmap().
Referenced by SCH_BITMAP::MirrorHorizontally(), and SCH_BITMAP::MirrorVertically().
void BITMAP_BASE::PlotImage | ( | PLOTTER * | aPlotter, |
const wxPoint & | aPos, | ||
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 340 of file bitmap_base.cpp.
References GetScalingFactor(), m_image, NULL, 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 104 of file bitmap_base.cpp.
References m_bitmap, and m_image.
Referenced by SCH_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 87 of file bitmap_base.cpp.
|
inline |
Definition at line 87 of file bitmap_base.h.
References m_bitmap, and m_image.
Referenced by Mirror(), DIALOG_IMAGE_EDITOR::OnGreyScaleConvert(), 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 330 of file bitmap_base.cpp.
References m_image, and RebuildBitmap().
Referenced by SCH_BITMAP::Rotate().
bool BITMAP_BASE::SaveData | ( | FILE * | aFile | ) | const |
Write the bitmap data to aFile.
The file format is png, in hexadecimal form. If the hexadecimal data is converted to binary it gives exactly a .png image data.
aFile | The FILE to write to. |
Definition at line 122 of file bitmap_base.cpp.
References m_image.
Referenced by DS_DATA_MODEL_IO::format().
void BITMAP_BASE::SaveData | ( | wxArrayString & | aPngStrings | ) | const |
Write the bitmap data to an array string.
The format is png, in Hexadecimal form. If the hexadecimal data is converted to binary it gives exactly a .png image data.
aPngStrings | The wxArrayString to write to. |
Definition at line 152 of file bitmap_base.cpp.
|
inline |
|
inline |
|
inline |
Definition at line 68 of file bitmap_base.h.
References m_pixelSizeIu.
Referenced by PLEDITOR_PRINTOUT::PrintPage(), PL_EDITOR_FRAME::PrintPage(), DS_DATA_ITEM_BITMAP::SyncDrawItems(), and TEST_BITMAP_BASE_FIXTURE::TEST_BITMAP_BASE_FIXTURE().
|
inline |
Definition at line 80 of file bitmap_base.h.
References m_scale.
Referenced by DRAWING_SHEET_READER_PARSER::parseBitmap(), SCH_BITMAP::SetImageScale(), DS_DATA_ITEM_BITMAP::SetPPI(), TEST_BITMAP_BASE_FIXTURE::TEST_BITMAP_BASE_FIXTURE(), and DIALOG_IMAGE_EDITOR::TransferToImage().
|
private |
Definition at line 240 of file bitmap_base.h.
Referenced by BITMAP_BASE(), DrawBitmap(), GetSize(), ImportData(), LoadData(), ReadImageFile(), RebuildBitmap(), SetBitmap(), and ~BITMAP_BASE().
|
private |
Definition at line 239 of file bitmap_base.h.
Referenced by BITMAP_BASE(), GetImageData(), GetSizePixels(), ImportData(), LoadData(), Mirror(), PlotImage(), ReadImageFile(), RebuildBitmap(), Rotate(), SaveData(), SetImage(), and ~BITMAP_BASE().
|
private |
Definition at line 241 of file bitmap_base.h.
Referenced by BITMAP_BASE(), GetPixelSizeIu(), GetScalingFactor(), ImportData(), and SetPixelSizeIu().
|
private |
Definition at line 245 of file bitmap_base.h.
Referenced by BITMAP_BASE(), GetPPI(), and ImportData().
|
private |
Definition at line 237 of file bitmap_base.h.
Referenced by BITMAP_BASE(), GetScale(), GetScalingFactor(), ImportData(), and SetScale().