From 03aea20f517ef38779b5eacec9d3237e53c1e3b1 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 7 Oct 2013 22:07:40 +0200 Subject: [PATCH] [DEV] code style de lundi --- egami/Image.cpp | 3 +-- egami/egami.cpp | 31 ++++++++++++++----------------- egami/egami.h | 6 +++--- egami/wrapperBMP.cpp | 39 ++++++++++++++++----------------------- egami/wrapperPNG.cpp | 28 +++++++++------------------- egami/wrapperSVG.cpp | 3 +-- 6 files changed, 44 insertions(+), 66 deletions(-) diff --git a/egami/Image.cpp b/egami/Image.cpp index c822bad..b2d0c6c 100644 --- a/egami/Image.cpp +++ b/egami/Image.cpp @@ -25,8 +25,7 @@ void egami::Image::resize(const ivec2& _size, const etk::Color<>& _color) { m_data.reSize(m_size.x()*m_size.y(), _color); } -void egami::Image::resize(const ivec2& _size, const ivec2& _startPos) -{ +void egami::Image::resize(const ivec2& _size, const ivec2& _startPos) { if (_size == m_size) { // same size == > nothing to do ... return; diff --git a/egami/egami.cpp b/egami/egami.cpp index aeb17a9..00432d3 100644 --- a/egami/egami.cpp +++ b/egami/egami.cpp @@ -13,30 +13,28 @@ #include #include -bool egami::Scalable(const etk::UString& _fileName) -{ - if (true == _fileName.EndWith(".svg") ) { +bool egami::scalable(const etk::UString& _fileName) { + if (true == _fileName.endWith(".svg") ) { return true; } return false; } -bool egami::Load(egami::Image& _output, const etk::UString& _fileName, const ivec2& _size) -{ +bool egami::load(egami::Image& _output, const etk::UString& _fileName, const ivec2& _size) { etk::UString tmpName = _fileName.toLower(); // select the corect Loader : - if (true == tmpName.EndWith(".bmp") ) { - if (false == egami::LoadBMP(_fileName, _output)) { + if (true == tmpName.endWith(".bmp") ) { + if (false == egami::loadBMP(_fileName, _output)) { EGAMI_ERROR("Error to load BMP file '" << _fileName << "'"); return false; } - } else if (true == tmpName.EndWith(".svg") ) { - if (false == egami::LoadSVG(_fileName, _output, _size)) { + } else if (true == tmpName.endWith(".svg") ) { + if (false == egami::loadSVG(_fileName, _output, _size)) { EGAMI_ERROR("Error to load SVG file '" << _fileName << "'"); return false; } - } else if (true == tmpName.EndWith(".png") ) { - if (false == egami::LoadPNG(_fileName, _output)) { + } else if (true == tmpName.endWith(".png") ) { + if (false == egami::loadPNG(_fileName, _output)) { EGAMI_ERROR("Error to load PNG file '" << _fileName << "'"); return false; } @@ -47,19 +45,18 @@ bool egami::Load(egami::Image& _output, const etk::UString& _fileName, const ive return true; } -bool egami::Store(const egami::Image& _input, const etk::UString& _fileName) -{ +bool egami::store(const egami::Image& _input, const etk::UString& _fileName) { etk::UString tmpName = _fileName.toLower(); // select the corect Loader : - if (true == tmpName.EndWith(".bmp") ) { - if (false == egami::StoreBMP(_fileName, _input)) { + if (true == tmpName.endWith(".bmp") ) { + if (false == egami::storeBMP(_fileName, _input)) { EGAMI_ERROR("Error to load BMP file '" << _fileName << "'"); return false; } - } else if (true == tmpName.EndWith(".svg") ) { + } else if (true == tmpName.endWith(".svg") ) { EGAMI_ERROR("Can not store in SVG file '" << _fileName << "'"); return false; - } else if (true == tmpName.EndWith(".png") ) { + } else if (true == tmpName.endWith(".png") ) { EGAMI_ERROR("Can not store in PNG file '" << _fileName << "'"); return false; } else { diff --git a/egami/egami.h b/egami/egami.h index 628d523..bf87977 100644 --- a/egami/egami.h +++ b/egami/egami.h @@ -24,20 +24,20 @@ namespace egami * @param[in] _size Dimention of the file when resizable (SVG). * @return true if the file is corectly loaded, false otherwise. */ - bool Load(egami::Image& _output, const etk::UString& _fileName, const ivec2& _size=ivec2(-1,-1) ); + bool load(egami::Image& _output, const etk::UString& _fileName, const ivec2& _size=ivec2(-1,-1) ); /** * @brief Save an image in a file. * @param[in] _input Data of the image. * @param[in] _fileName Name of the file. * @return true if the file is corectly Stored, false otherwise */ - bool Store(const egami::Image& _input, const etk::UString& _fileName); + bool store(const egami::Image& _input, const etk::UString& _fileName); /** * @brief know if a file can have multiple size definition. * @param[in] _fileName Name of the file. * @return true if the format is scalable. */ - bool Scalable(const etk::UString& _fileName); + bool scalable(const etk::UString& _fileName); }; #endif diff --git a/egami/wrapperBMP.cpp b/egami/wrapperBMP.cpp index 7438ef7..91d7a3d 100644 --- a/egami/wrapperBMP.cpp +++ b/egami/wrapperBMP.cpp @@ -19,7 +19,7 @@ extern "C" { int32_t bfReserved; int32_t bfOffBits; }; - struct bitmapFileHeader { + struct bitmapInfoHeader { int32_t biSize; int32_t biWidth; int32_t biHeight; @@ -46,11 +46,11 @@ typedef enum { #define __class__ "wrapperBMP" bool egami::loadBMP(const etk::UString& _inputFile, egami::Image& _ouputImage) { - modeBitmap_te m_dataMode = BITS_16_R5G6B5; - int32_t m_width = 0; - int32_t m_height = 0; + modeBitmap_te m_dataMode = BITS_16_R5G6B5; + int32_t m_width = 0; + int32_t m_height = 0; struct bitmapFileHeader m_FileHeader; - struct bitmapFileHeader m_InfoHeader; + struct bitmapInfoHeader m_InfoHeader; etk::FSNode fileName(_inputFile); // get the fileSize ... @@ -72,7 +72,7 @@ bool egami::loadBMP(const etk::UString& _inputFile, egami::Image& _ouputImage) { fileName.fileClose(); return false; } - if (fileName.fileRead(&m_InfoHeader,sizeof(struct bitmapFileHeader),1) != 1) { + if (fileName.fileRead(&m_InfoHeader,sizeof(struct bitmapInfoHeader),1) != 1) { EGAMI_ERROR("error loading file header"); fileName.fileClose(); return false; @@ -124,8 +124,7 @@ bool egami::loadBMP(const etk::UString& _inputFile, egami::Image& _ouputImage) { _ouputImage.resize(ivec2(m_width,m_height)); uint8_t* m_data = NULL; - if(0 != m_InfoHeader.biSizeImage) - { + if(0 != m_InfoHeader.biSizeImage) { m_data=new uint8_t[m_InfoHeader.biSizeImage]; if (fileName.fileRead(m_data,m_InfoHeader.biSizeImage,1) != 1){ EGAMI_CRITICAL("Can not read the file with the good size..."); @@ -136,10 +135,8 @@ bool egami::loadBMP(const etk::UString& _inputFile, egami::Image& _ouputImage) { etk::Color<> tmpColor(0,0,0,0); // need now to generate RGBA data ... - switch(m_dataMode) - { - case BITS_16_R5G6B5: - { + switch(m_dataMode) { + case BITS_16_R5G6B5: { uint16_t * pointer = (uint16_t*)m_data; for(int32_t yyy=0; yyy(png_get_io_ptr(png_ptr)); if (NULL!=fileNode) { fileNode->fileRead(data, 1, length); @@ -43,8 +42,7 @@ static void localFlushData(png_structp png_ptr) } */ -bool egami::loadPNG(const etk::UString& _inputFile, egami::Image& _ouputImage) -{ +bool egami::loadPNG(const etk::UString& _inputFile, egami::Image& _ouputImage) { etk::FSNode fileName(_inputFile); if (false == fileName.exist()) { @@ -69,8 +67,7 @@ bool egami::loadPNG(const etk::UString& _inputFile, egami::Image& _ouputImage) fileName.fileClose(); return false; } - if (png_sig_cmp(header, 0, 8)) - { + if (png_sig_cmp(header, 0, 8)) { EGAMI_ERROR("Invalid file :" << fileName); return false; } @@ -108,8 +105,7 @@ bool egami::loadPNG(const etk::UString& _inputFile, egami::Image& _ouputImage) rowbytes = width * ((bit_depth == 16) ? 8 : 4); // File read - for (y = 0; y < height; y++) - { + for (y = 0; y < height; y++) { row_pointers[y] = (png_byte*) malloc(rowbytes); } png_read_image(png_ptr, row_pointers); @@ -117,15 +113,12 @@ bool egami::loadPNG(const etk::UString& _inputFile, egami::Image& _ouputImage) png_set_strip_16(png_ptr); etk::Color<> tmpColor(0,0,0,0); - switch (png_get_color_type(png_ptr, info_ptr) ) - { + switch (png_get_color_type(png_ptr, info_ptr) ) { case PNG_COLOR_TYPE_RGBA: // Conversion to OpenGL texture - for (y = 0; y < height; y++) - { + for (y = 0; y < height; y++) { png_byte* row = row_pointers[y]; - for (x = 0; x < width; x++) - { + for (x = 0; x < width; x++) { png_byte* ptr = &(row[x*4]); tmpColor.set(ptr[0], ptr[1],ptr[2],ptr[3]); _ouputImage.set(ivec2(x,y), tmpColor); @@ -135,11 +128,9 @@ bool egami::loadPNG(const etk::UString& _inputFile, egami::Image& _ouputImage) break; case PNG_COLOR_TYPE_RGB: // Conversion to OpenGL texture - for (y = 0; y < height; y++) - { + for (y = 0; y < height; y++) { png_byte* row = row_pointers[y]; - for (x = 0; x < width; x++) - { + for (x = 0; x < width; x++) { png_byte* ptr = &(row[x*3]); tmpColor.set(ptr[0], ptr[1],ptr[2]); _ouputImage.set(ivec2(x,y), tmpColor); @@ -151,7 +142,6 @@ bool egami::loadPNG(const etk::UString& _inputFile, egami::Image& _ouputImage) EGAMI_ERROR("Must be RGBA/RGB"); return false; } - fileName.fileClose(); return true; } diff --git a/egami/wrapperSVG.cpp b/egami/wrapperSVG.cpp index b9ea9ad..87022e5 100644 --- a/egami/wrapperSVG.cpp +++ b/egami/wrapperSVG.cpp @@ -18,8 +18,7 @@ #define __class__ "wrapperSVG" -bool egami::loadSVG(const etk::UString& _fileName, egami::Image& _ouputImage, const ivec2& _size) -{ +bool egami::loadSVG(const etk::UString& _fileName, egami::Image& _ouputImage, const ivec2& _size) { esvg::Document m_element(_fileName); if (false == m_element.isLoadOk()) { EGAMI_ERROR("Error to load SVG file " << _fileName );