Apply clang-format to bmpimage.cpp

v0.27.3
Luis Diaz Mas 8 years ago
parent 6d9e0b5b3e
commit d0a1c6d19d

@ -27,25 +27,24 @@
// included header files // included header files
#include "config.h" #include "config.h"
#include "bmpimage.hpp"
#include "image.hpp"
#include "basicio.hpp" #include "basicio.hpp"
#include "bmpimage.hpp"
#include "error.hpp" #include "error.hpp"
#include "futils.hpp" #include "futils.hpp"
#include "image.hpp"
// + standard includes // + standard includes
#include <string>
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#include <string>
// ***************************************************************************** // *****************************************************************************
// class member definitions // class member definitions
namespace Exiv2 { namespace Exiv2
{
BmpImage::BmpImage(BasicIo::AutoPtr io) BmpImage::BmpImage(BasicIo::AutoPtr io) : Image(ImageType::bmp, mdNone, io)
: Image(ImageType::bmp, mdNone, io)
{ {
} // BmpImage::BmpImage }
std::string BmpImage::mimeType() const std::string BmpImage::mimeType() const
{ {
@ -75,14 +74,12 @@ namespace Exiv2 {
#ifdef DEBUG #ifdef DEBUG
std::cerr << "Exiv2::BmpImage::readMetadata: Reading Windows bitmap file " << io_->path() << "\n"; std::cerr << "Exiv2::BmpImage::readMetadata: Reading Windows bitmap file " << io_->path() << "\n";
#endif #endif
if (io_->open() != 0) if (io_->open() != 0) {
{
throw Error(9, io_->path(), strError()); throw Error(9, io_->path(), strError());
} }
IoCloser closer(*io_); IoCloser closer(*io_);
// Ensure that this is the correct image type // Ensure that this is the correct image type
if (!isBmpType(*io_, false)) if (!isBmpType(*io_, false)) {
{
if (io_->error() || io_->eof()) throw Error(14); if (io_->error() || io_->eof()) throw Error(14);
throw Error(3, "BMP"); throw Error(3, "BMP");
} }
@ -110,26 +107,24 @@ namespace Exiv2 {
50 4 bytes important colors number of "important" colors 50 4 bytes important colors number of "important" colors
*/ */
byte buf[54]; byte buf[54];
if (io_->read(buf, sizeof(buf)) == sizeof(buf)) if (io_->read(buf, sizeof(buf)) == sizeof(buf)) {
{
pixelWidth_ = getLong(buf + 18, littleEndian); pixelWidth_ = getLong(buf + 18, littleEndian);
pixelHeight_ = getLong(buf + 22, littleEndian); pixelHeight_ = getLong(buf + 22, littleEndian);
} }
} // BmpImage::readMetadata }
void BmpImage::writeMetadata() void BmpImage::writeMetadata()
{ {
// Todo: implement me! // Todo: implement me!
throw(Error(31, "BMP")); throw(Error(31, "BMP"));
} // BmpImage::writeMetadata }
// ************************************************************************* // *************************************************************************
// free functions // free functions
Image::AutoPtr newBmpInstance(BasicIo::AutoPtr io, bool /*create*/) Image::AutoPtr newBmpInstance(BasicIo::AutoPtr io, bool /*create*/)
{ {
Image::AutoPtr image(new BmpImage(io)); Image::AutoPtr image(new BmpImage(io));
if (!image->good()) if (!image->good()) {
{
image.reset(); image.reset();
} }
return image; return image;
@ -138,18 +133,16 @@ namespace Exiv2 {
bool isBmpType(BasicIo& iIo, bool advance) bool isBmpType(BasicIo& iIo, bool advance)
{ {
const int32_t len = 2; const int32_t len = 2;
const unsigned char BmpImageId[2] = { 'B', 'M' }; const unsigned char BmpImageId[2] = {'B', 'M'};
byte buf[len]; byte buf[len];
iIo.read(buf, len); iIo.read(buf, len);
if (iIo.error() || iIo.eof()) if (iIo.error() || iIo.eof()) {
{
return false; return false;
} }
bool matched = (memcmp(buf, BmpImageId, len) == 0); bool matched = (memcmp(buf, BmpImageId, len) == 0);
if (!advance || !matched) if (!advance || !matched) {
{
iIo.seek(-len, BasicIo::cur); iIo.seek(-len, BasicIo::cur);
} }
return matched; return matched;
} }
} // namespace Exiv2 }

Loading…
Cancel
Save