Мелкие исправления
This commit is contained in:
parent
4af1f2f4a0
commit
570986b499
2 changed files with 41 additions and 2 deletions
31
bmpimage.cpp
31
bmpimage.cpp
|
@ -1,6 +1,6 @@
|
||||||
#include "bmpimage.h"
|
#include "bmpimage.h"
|
||||||
|
|
||||||
BMPImage::BMPImage(BitmapFileHeader &fileHeader, BITMAPINFOHEADER &infoHeader, Pixel **pixelArray) {
|
BMPImage::BMPImage(const BitmapFileHeader &fileHeader, const BITMAPINFOHEADER &infoHeader, Pixel **pixelArray) {
|
||||||
this->fileHeader = fileHeader;
|
this->fileHeader = fileHeader;
|
||||||
this->infoHeader = infoHeader;
|
this->infoHeader = infoHeader;
|
||||||
this->pixelArray = pixelArray;
|
this->pixelArray = pixelArray;
|
||||||
|
@ -24,6 +24,35 @@ void BMPImage::write(const std::string &filename) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pixel **BMPImage::pixels(){
|
||||||
|
return this->pixelArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pixel **BMPImage::pixels_copy() {
|
||||||
|
Pixel **newPixelArray;
|
||||||
|
newPixelArray = new Pixel *[this->infoHeader.BitmapHeight];
|
||||||
|
for (int i = 0; i < this->infoHeader.BitmapHeight; ++i) {
|
||||||
|
newPixelArray[i] = new Pixel[this->infoHeader.BitmapWidth];
|
||||||
|
std::copy(this->pixelArray[i], this->pixelArray[i] + this->infoHeader.BitmapWidth, newPixelArray[i]);
|
||||||
|
}
|
||||||
|
return newPixelArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
BitmapFileHeader BMPImage::fileHeader_copy() {
|
||||||
|
return this->fileHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
BITMAPINFOHEADER BMPImage::infoHeader_copy() {
|
||||||
|
return this->infoHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
BMPImage::~BMPImage() {
|
||||||
|
for (int i = 0; i < this->infoHeader.BitmapHeight; ++i) {
|
||||||
|
delete[] this->pixelArray[i];
|
||||||
|
}
|
||||||
|
delete[] this->pixelArray;
|
||||||
|
}
|
||||||
|
|
||||||
BMPImage readBMPImage(const std::string &filename) {
|
BMPImage readBMPImage(const std::string &filename) {
|
||||||
BitmapFileHeader bitmapFileHeader;
|
BitmapFileHeader bitmapFileHeader;
|
||||||
BITMAPINFOHEADER bitmapInfoHeader;
|
BITMAPINFOHEADER bitmapInfoHeader;
|
||||||
|
|
12
bmpimage.h
12
bmpimage.h
|
@ -45,12 +45,22 @@ class BMPImage {
|
||||||
BITMAPINFOHEADER infoHeader;
|
BITMAPINFOHEADER infoHeader;
|
||||||
Pixel **pixelArray;
|
Pixel **pixelArray;
|
||||||
public:
|
public:
|
||||||
BMPImage(BitmapFileHeader &fileHeader, BITMAPINFOHEADER &infoHeader, Pixel **pixelArray);
|
BMPImage(const BitmapFileHeader &fileHeader, const BITMAPINFOHEADER &infoHeader, Pixel **pixelArray);
|
||||||
|
|
||||||
|
~BMPImage();
|
||||||
|
|
||||||
[[nodiscard]] const uint32_t &width() const;
|
[[nodiscard]] const uint32_t &width() const;
|
||||||
|
|
||||||
[[nodiscard]] const uint32_t &height() const;
|
[[nodiscard]] const uint32_t &height() const;
|
||||||
|
|
||||||
|
[[nodiscard]] Pixel **pixels();
|
||||||
|
|
||||||
|
[[nodiscard]] Pixel **pixels_copy();
|
||||||
|
|
||||||
|
[[nodiscard]] BitmapFileHeader fileHeader_copy();
|
||||||
|
|
||||||
|
[[nodiscard]] BITMAPINFOHEADER infoHeader_copy();
|
||||||
|
|
||||||
void write(const std::string &);
|
void write(const std::string &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue