[haiku-commits] haiku: hrev46978 - src/add-ons/translators/gif

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 5 Mar 2014 21:36:37 +0100 (CET)

hrev46978 adds 3 changesets to branch 'master'
old head: 5b5f099fc0895326a8bae2c58c113f4b466bdf4e
new head: 01be25aefe233feefb17b8c70d7553dc789bee1a
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=01be25a+%5E5b5f099

----------------------------------------------------------------------------

5adf9d6: Use doxygen style comments as per guidelines
  
  Thanks Axel!

c030bef: GIFTranslator: Reorder includes
  
  Thanks Jérôme

01be25a: GIFTranslator: Refactor filling out BBitmap
  
  * Remove the NULL check since BBitmaps don't return NULL but check
    that it IsValid() instead.
  * Fill out the *out pointer directly instead of creating a temporary
    bitmap pointer.
  * Rename err to result.
  * Return B_OK unconditionally if we get to the end of the function.
  
  Thanks again Jérôme

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

2 files changed, 28 insertions(+), 32 deletions(-)
src/add-ons/translators/gif/GIFLoad.cpp       |  4 +-
src/add-ons/translators/gif/GIFTranslator.cpp | 56 +++++++++++------------

############################################################################

Commit:      5adf9d6ee5605453c0f6c31caaeb8efcc80d721c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=5adf9d6
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Mar  4 18:12:34 2014 UTC

Use doxygen style comments as per guidelines

Thanks Axel!

----------------------------------------------------------------------------

diff --git a/src/add-ons/translators/gif/GIFTranslator.cpp 
b/src/add-ons/translators/gif/GIFTranslator.cpp
index d33e656..3fdf72f 100644
--- a/src/add-ons/translators/gif/GIFTranslator.cpp
+++ b/src/add-ons/translators/gif/GIFTranslator.cpp
@@ -111,9 +111,9 @@ const uint32 kNumOutputFormats = sizeof(sOutputFormats) / 
sizeof(translation_for
 const uint32 kNumDefaultSettings = sizeof(sDefaultSettings) / 
sizeof(TranSetting);
 
 
-/* Look at first few bytes in stream to determine type - throw it back
- * if it is not a GIF or a BBitmap that we understand.
- */
+/*!    Look at first few bytes in stream to determine type - throw it back
+       if it is not a GIF or a BBitmap that we understand.
+*/
 bool
 DetermineType(BPositionIO* source, bool* isGif)
 {
@@ -187,8 +187,8 @@ GetBitmap(BPositionIO* in, BBitmap** out)
 }
 
 
-/*     Required identify function - may need to read entire header, not sure
- */
+/*!    Required identify function - may need to read entire header, not sure
+*/
 status_t
 GIFTranslator::DerivedIdentify(BPositionIO* inSource,
        const translation_format* inFormat, BMessage* ioExtension,
@@ -231,9 +231,9 @@ GIFTranslator::DerivedIdentify(BPositionIO* inSource,
 }
 
 
-/* Main required function - assumes that an incoming GIF must be translated
- * to a BBitmap, and vice versa - this could be improved
- */
+/*!    Main required function - assumes that an incoming GIF must be translated
+       to a BBitmap, and vice versa - this could be improved
+*/
 status_t
 GIFTranslator::DerivedTranslate(BPositionIO* inSource,
        const translator_info* inInfo, BMessage* ioExtension, uint32 outType,

############################################################################

Commit:      c030befbf93382ba9feb91787c97573ca5a4cee6
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c030bef
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Wed Mar  5 20:16:44 2014 UTC

GIFTranslator: Reorder includes

Thanks Jérôme

----------------------------------------------------------------------------

diff --git a/src/add-ons/translators/gif/GIFLoad.cpp 
b/src/add-ons/translators/gif/GIFLoad.cpp
index ce9bb30..d7f0c7d 100644
--- a/src/add-ons/translators/gif/GIFLoad.cpp
+++ b/src/add-ons/translators/gif/GIFLoad.cpp
@@ -18,13 +18,13 @@
 
 #include "GIFLoad.h"
 
-#include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <syslog.h>
 
 #include <ByteOrder.h>
-#include <TranslatorFormats.h>
 #include <InterfaceDefs.h>
+#include <TranslatorFormats.h>
 
 #include "GIFPrivate.h"
 
diff --git a/src/add-ons/translators/gif/GIFTranslator.cpp 
b/src/add-ons/translators/gif/GIFTranslator.cpp
index 3fdf72f..ef1615d 100644
--- a/src/add-ons/translators/gif/GIFTranslator.cpp
+++ b/src/add-ons/translators/gif/GIFTranslator.cpp
@@ -28,13 +28,13 @@
 #include <Catalog.h>
 #include <DataIO.h>
 #include <InterfaceDefs.h>
-#include <TypeConstants.h>
 #include <TranslatorAddOn.h>
 #include <TranslatorFormats.h>
+#include <TypeConstants.h>
 
-#include "GIFView.h"
-#include "GIFSave.h"
 #include "GIFLoad.h"
+#include "GIFSave.h"
+#include "GIFView.h"
 #include "TranslatorWindow.h"
 
 

############################################################################

Revision:    hrev46978
Commit:      01be25aefe233feefb17b8c70d7553dc789bee1a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=01be25a
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Wed Mar  5 20:27:12 2014 UTC

GIFTranslator: Refactor filling out BBitmap

* Remove the NULL check since BBitmaps don't return NULL but check
  that it IsValid() instead.
* Fill out the *out pointer directly instead of creating a temporary
  bitmap pointer.
* Rename err to result.
* Return B_OK unconditionally if we get to the end of the function.

Thanks again Jérôme

----------------------------------------------------------------------------

diff --git a/src/add-ons/translators/gif/GIFTranslator.cpp 
b/src/add-ons/translators/gif/GIFTranslator.cpp
index ef1615d..1eb442d 100644
--- a/src/add-ons/translators/gif/GIFTranslator.cpp
+++ b/src/add-ons/translators/gif/GIFTranslator.cpp
@@ -121,6 +121,7 @@ DetermineType(BPositionIO* source, bool* isGif)
        *isGif = true;
        if (source->Read(header, 6) != 6)
                return false;
+
        header[6] = 0x00;
 
        if (strcmp((char*)header, "GIF87a") != 0
@@ -152,8 +153,8 @@ status_t
 GetBitmap(BPositionIO* in, BBitmap** out)
 {
        TranslatorBitmap header;
-       status_t err = in->Read(&header, sizeof(header));
-       if (err != sizeof(header))
+       status_t result = in->Read(&header, sizeof(header));
+       if (result != sizeof(header))
                return B_IO_ERROR;
 
        header.magic = B_BENDIAN_TO_HOST_INT32(header.magic);
@@ -166,24 +167,19 @@ GetBitmap(BPositionIO* in, BBitmap** out)
        header.dataSize = B_BENDIAN_TO_HOST_INT32(header.dataSize);
 
        // dump data from stream into a BBitmap
-       BBitmap* bitmap = new BBitmap(header.bounds, header.colors);
-       *out = bitmap;
-       if (bitmap == NULL)
-               return B_NO_MEMORY;
-
-       unsigned char* bits = (unsigned char*)bitmap->Bits();
-       if (bits == NULL) {
-               delete bitmap;
+       *out = new BBitmap(header.bounds, header.colors);
+       if (!(*out)->IsValid()) {
+               delete *out;
                return B_NO_MEMORY;
        }
 
-       err = in->Read(bits, header.dataSize);
-       if (err == (status_t)header.dataSize)
-               return B_OK;
-       else {
-               delete bitmap;
+       result = in->Read((*out)->Bits(), header.dataSize);
+       if (result != (status_t)header.dataSize) {
+               delete *out;
                return B_IO_ERROR;
        }
+
+       return B_OK;
 }
 
 
@@ -256,15 +252,15 @@ GIFTranslator::DerivedTranslate(BPositionIO* inSource,
        if (!isGif && inInfo->type != B_TRANSLATOR_BITMAP)
                return B_NO_TRANSLATOR;
 
-       status_t err = B_OK;
+       status_t result = B_OK;
        bigtime_t now = system_time();
 
        if (!isGif) {
                // BBitmap to GIF
                BBitmap* bitmap;
-               err = GetBitmap(inSource, &bitmap);
-               if (err != B_OK)
-                       return err;
+               result = GetBitmap(inSource, &bitmap);
+               if (result != B_OK)
+                       return result;
 
                GIFSave* gifSave = new GIFSave(bitmap, outDestination, 
fSettings);
                if (gifSave->fatalerror) {


Other related posts: