![]() |
KSquare Utilities
|
Used to encode and decode BMP Images. More...
#include <BMPImage.h>
Classes | |
| struct | Bmp1BitRec |
| struct | Bmp4BitRecs |
| struct | BMP_24BitPixel |
| class | CodedPixels |
| This object is used to help encode the data stored in BMPImage::image into 8 or 4 bit compressed formats used by BMP files. *. More... | |
| struct | CodePair |
| class | PalletBuilder |
Public Types | |
| typedef CodePair * | CodePairPtr |
Public Member Functions | |
| BmpImage (kkint32 _height, kkint32 _width, kkint32 _numOfColors) | |
| BmpImage (const KKStr &_fileName, bool &successful) | |
| Constructs a BMP image from the file specified by '_fileName'. More... | |
| BmpImage (const Raster &raster) | |
| Constructs a BMPImage instance from a Raster image; this is one way to save a Raster image to disk. More... | |
| ~BmpImage () | |
| void | AddPixel (kkuint32 row, kkuint32 col, uchar pixValue) |
| bool | AreThereEdgePixels () |
| void | Binarize () |
| const uchar * | BlueRow (kkint32 row) const |
| Returns the specified Row from the Blue Channel. More... | |
| void | ClearImage () |
| bool | Color () const |
| Returns true if a Color image. More... | |
| void | DoubleSize () |
| void | DownSize () |
| void | EliminateVerticalLines () |
| const KKStr & | FileName () const |
| bool | FourBitUncompressed () |
| kkuint32 | Height () const |
| uchar ** | Image () |
| Returns back two dimension matrix of image; if color it will be the green channel. More... | |
| const uchar * | ImageRow (kkint32 row) const |
| Returns the specified Row from the Green Channel. More... | |
| void | InitializeFields (kkint32 _height, kkint32 _width) |
| uchar | MaxPixVal () const |
| uchar & | Pixel (kkint32 row, kkint32 col) |
| void | Print () |
| void | ReAllocateForBiggerScreen () |
| Used to expand dimensions of image by 6 pixels so as to make sure that no image is along the edge. More... | |
| const uchar * | RedRow (kkint32 row) const |
| Returns the specified Row from the Red Channel. More... | |
| void | Save (const KKStr &fileName) |
| void | SaveGrayscaleInverted4Bit (const KKStr &_fileName) |
| Saves image using 4 bit compressed gray-scale where Background = 255 and foreground = 0. More... | |
| void | SaveGrayscaleInverted8Bit (const KKStr &_fileName) |
| Saves image using compressed gray-scale where Background = 255 and foreground = 0. More... | |
| void | Set16Colors () |
| void | Set256Colors () |
| void | SetPaletteEntry (kkint32 palletIndex, const PixelValue &pixValue) |
| void | SetPixelValue (kkint32 row, kkint32 col, kkint32 pixel) |
| Will set the pixel value of the specified row and col to 'pixel'. More... | |
| kkuint32 | Width () const |
Used to encode and decode BMP Images.
Purpose of this class it to facilitate the loading and saving of BMP Image files. Not all formats are supported, but the compressed version is, which most others don't support. As a result this class will write considerably smaller BMP files than other utilities that I have tried. This results in faster writing images due to less disk-io.
This object was originally designed to work in conjunction with Image Extraction. It requires no other libraries and can read and write BMP files.
When ImageExtraction creates a Bmp file it will provide pixel values between 0 and 7, where 0 is the background and 7 is the foreground. This is a result of the SIPPER 2 and 3 Formats and may change in the future. When saving the BMP file BMPImage will map these values through the palette to 0=255, 1=219, 2=182, 3=146, 4=109, 5=73, 6=36, 7=0 resulting in a white background and a Black foreground.
Definition at line 49 of file BMPImage.h.
| typedef CodePair* KKB::BmpImage::CodePairPtr |
Definition at line 214 of file BMPImage.h.
Definition at line 687 of file BMPImage.cpp.
References InitializeFields(), and KKB::KKStr::KKStr().
| BmpImage::BmpImage | ( | const KKStr & | _fileName, |
| bool & | successful | ||
| ) |
Constructs a BMP image from the file specified by '_fileName'.
| [in] | _fileName | Name of file to load BMP image from. |
| [out] | successful | Returns true if file successful in loading. |
Definition at line 449 of file BMPImage.cpp.
References KKB::KKStr::KKStr(), KKB::osFOPEN(), and KKB::KKStr::Str().
Referenced by KKB::ReadImage().
| BmpImage::BmpImage | ( | const Raster & | raster | ) |
Constructs a BMPImage instance from a Raster image; this is one way to save a Raster image to disk.
Definition at line 706 of file BMPImage.cpp.
References KKB::Raster::Blue(), KKB::Raster::Color(), KKB::Raster::Height(), InitializeFields(), KKB::KKStr::operator=(), KKB::Raster::Red(), KKB::Raster::Rows(), and KKB::Raster::Width().
Referenced by KKB::SaveImage(), KKB::SaveImageGrayscaleInverted4Bit(), and KKB::SaveImageGrayscaleInverted8Bit().
| BmpImage::~BmpImage | ( | ) |
Definition at line 743 of file BMPImage.cpp.
Definition at line 2630 of file BMPImage.cpp.
| bool BmpImage::AreThereEdgePixels | ( | ) |
| void BmpImage::Binarize | ( | ) |
Definition at line 2189 of file BMPImage.cpp.
Returns the specified Row from the Blue Channel.
Definition at line 2652 of file BMPImage.cpp.
References Height(), KKB::KKException::KKException(), KKB::KKStr::operator+(), KKB::operator+(), and KKB::StrFromInt32().
Referenced by KKB::Raster::Raster().
| void BmpImage::ClearImage | ( | ) |
Definition at line 2640 of file BMPImage.cpp.
|
inline |
Returns true if a Color image.
Definition at line 118 of file BMPImage.h.
Referenced by KKB::Raster::Raster().
| void KKB::BmpImage::DoubleSize | ( | ) |
| void BmpImage::DownSize | ( | ) |
Definition at line 1917 of file BMPImage.cpp.
| void BmpImage::EliminateVerticalLines | ( | ) |
Definition at line 2063 of file BMPImage.cpp.
|
inline |
Definition at line 121 of file BMPImage.h.
Referenced by KKB::Raster::Raster().
| bool BmpImage::FourBitUncompressed | ( | ) |
Definition at line 2709 of file BMPImage.cpp.
|
inline |
Definition at line 125 of file BMPImage.h.
Referenced by AreThereEdgePixels(), BlueRow(), KKB::Raster::CreatePaddedRaster(), ImageRow(), KKB::Raster::Raster(), and RedRow().
|
inline |
Returns back two dimension matrix of image; if color it will be the green channel.
Definition at line 130 of file BMPImage.h.
Returns the specified Row from the Green Channel.
Definition at line 2672 of file BMPImage.cpp.
References Height(), KKB::KKException::KKException(), KKB::KKStr::operator+(), KKB::operator+(), and KKB::StrFromInt32().
Referenced by KKB::Raster::CreatePaddedRaster(), and KKB::Raster::Raster().
|
inline |
Definition at line 138 of file BMPImage.h.
Definition at line 1958 of file BMPImage.cpp.
| void BmpImage::Print | ( | ) |
Definition at line 2168 of file BMPImage.cpp.
References KKB::operator<<().
| void BmpImage::ReAllocateForBiggerScreen | ( | ) |
Used to expand dimensions of image by 6 pixels so as to make sure that no image is along the edge.
Definition at line 1318 of file BMPImage.cpp.
Returns the specified Row from the Red Channel.
Definition at line 2690 of file BMPImage.cpp.
References Height(), KKB::KKException::KKException(), KKB::KKStr::operator+(), KKB::operator+(), and KKB::StrFromInt32().
Referenced by KKB::Raster::Raster().
| void BmpImage::Save | ( | const KKStr & | fileName | ) |
Definition at line 2331 of file BMPImage.cpp.
References KKB::KKStr::Concat(), KKB::KKException::KKException(), KKB::KKStr::operator+(), KKB::operator+(), KKB::KKStr::operator=(), KKB::osFOPEN(), and KKB::KKStr::Str().
Referenced by KKB::SaveImage().
| void BmpImage::SaveGrayscaleInverted4Bit | ( | const KKStr & | _fileName | ) |
Saves image using 4 bit compressed gray-scale where Background = 255 and foreground = 0.
If image is color will convert to gray-scale 1st. Palette will be set to 0 = 255, 1 = 238, 2 = 221, 3 = 204... 255 = 0.
Definition at line 2207 of file BMPImage.cpp.
References KKB::BmpImage::CodedPixels::AddPixel(), KKB::KKStr::Concat(), KKB::BmpImage::CodedPixels::CreatePixelDataStructure4Bit(), KKB::BmpImage::CodedPixels::EOL(), KKB::KKException::KKException(), KKB::KKStr::operator+(), KKB::operator+(), KKB::KKStr::operator=(), KKB::osFOPEN(), and KKB::KKStr::Str().
Referenced by KKB::SaveImageGrayscaleInverted4Bit().
| void BmpImage::SaveGrayscaleInverted8Bit | ( | const KKStr & | _fileName | ) |
Saves image using compressed gray-scale where Background = 255 and foreground = 0.
If image is color will convert to gray-scale 1st. Palette will be set to 0 = 255, 1 = 254, 2 = 253, ... 255 = 0.
Definition at line 2268 of file BMPImage.cpp.
References KKB::BmpImage::CodedPixels::AddPixel(), KKB::KKStr::Concat(), KKB::BmpImage::CodedPixels::CreatePixelDataStructure8Bit(), KKB::BmpImage::CodedPixels::EOL(), KKB::KKException::KKException(), KKB::KKStr::operator+(), KKB::operator+(), KKB::KKStr::operator=(), KKB::osFOPEN(), and KKB::KKStr::Str().
Referenced by KKB::SaveImageGrayscaleInverted8Bit().
| void BmpImage::Set16Colors | ( | ) |
Definition at line 1194 of file BMPImage.cpp.
| void BmpImage::Set256Colors | ( | ) |
Definition at line 1208 of file BMPImage.cpp.
| void BmpImage::SetPaletteEntry | ( | kkint32 | palletIndex, |
| const PixelValue & | pixValue | ||
| ) |
Definition at line 935 of file BMPImage.cpp.
Will set the pixel value of the specified row and col to 'pixel'.
Definition at line 1967 of file BMPImage.cpp.
|
inline |
Definition at line 140 of file BMPImage.h.
Referenced by AreThereEdgePixels(), KKB::Raster::CreatePaddedRaster(), and KKB::Raster::Raster().