[4.0] Exposing Exif Image metadata
[platform/core/uifw/dali-adaptor.git] / platform-abstractions / tizen / image-loaders / loader-wbmp.cpp
index 8014bc6..44560bb 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
-#include <dali/integration-api/bitmap.h>
-#include <dali/public-api/common/dali-vector.h>
+#include <adaptors/devel-api/adaptor-framework/pixel-buffer.h>
 
 namespace Dali
 {
-using Integration::Bitmap;
-using Dali::Integration::PixelBuffer;
+
 namespace TizenPlatform
 {
 
@@ -77,12 +75,12 @@ int extractMultiByteInteger(unsigned int *data, void *map, size_t length, size_t
     {
       return -1;
     }
-    buf = ((unsigned char *) map)[(*position)++];
+    buf = reinterpret_cast< unsigned char * >( map )[(*position)++];
     targetMultiByteInteger = (targetMultiByteInteger << 7) | (buf & 0x7f);
 
     if ((buf & 0x80) == 0)
     {
-      DALI_LOG_INFO(gLogFilter, Debug::Verbose, "position: %d, readBufCount: %d", *position, readBufCount);
+      DALI_LOG_INFO(gLogFilter, Debug::Verbose, "position: %d, readBufCount: %d\n", *position, readBufCount);
       break;
     }
   }
@@ -92,7 +90,7 @@ int extractMultiByteInteger(unsigned int *data, void *map, size_t length, size_t
 
 }// end unnamed namespace
 
-bool LoadBitmapFromWbmp( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
+bool LoadBitmapFromWbmp( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
 {
   FILE* const fp = input.file;
   if(fp == NULL)
@@ -102,14 +100,13 @@ bool LoadBitmapFromWbmp( const ResourceLoadingClient& client, const ImageLoader:
   }
   Dali::Vector<unsigned char> map;
   Dali::Vector<unsigned char> surface;//unsigned int
-  PixelBuffer* pixels = NULL;
   size_t position = 0;
 
-  unsigned int  w, h;
+  unsigned int w, h;
   unsigned int type;
   unsigned int line_length;
   unsigned char *line = NULL;
-  int cur = 0, x, y;
+  unsigned int cur = 0, x, y;
 
   if( fseek(fp,0,SEEK_END) )
   {
@@ -149,7 +146,7 @@ bool LoadBitmapFromWbmp( const ResourceLoadingClient& client, const ImageLoader:
 
   if(fread(&map[0], 1, fsize, fp) != fsize)
   {
-    DALI_LOG_WARNING("image file read opeation error!");
+    DALI_LOG_WARNING("image file read opeation error!\n");
     return false;
   }
 
@@ -183,7 +180,7 @@ bool LoadBitmapFromWbmp( const ResourceLoadingClient& client, const ImageLoader:
   memset(&surface[0], 0, w * h ); // w * h * 4
 
   line_length = (w + 7) >> 3;
-  for (y = 0; y < (int)h; y ++)
+  for (y = 0; y < h; y ++)
   {
     if (position + line_length > fsize)
     {
@@ -191,7 +188,7 @@ bool LoadBitmapFromWbmp( const ResourceLoadingClient& client, const ImageLoader:
     }
     line = &map[0] + position;
     position += line_length;
-    for (x = 0; x < (int)w; x++)
+    for (x = 0; x < w; x++)
     {
       int idx = x >> 3;
       int offset = 1 << (0x07 - (x & 0x07));
@@ -206,9 +203,9 @@ bool LoadBitmapFromWbmp( const ResourceLoadingClient& client, const ImageLoader:
       cur++;
     }
   }
-  pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(Pixel::L8, w, h);//Pixel::RGBA8888
+  auto pixels = (bitmap = Dali::Devel::PixelBuffer::New(w, h, Pixel::L8)).GetBuffer();
 
-  memcpy(pixels, (unsigned char*)&surface[0], w * h );//w * h * 4
+  memcpy( pixels, &surface[0], w * h ); //w * h * 4
 
   return true;
 }
@@ -263,13 +260,13 @@ bool LoadWbmpHeader( const ImageLoader::Input& input, unsigned int& width, unsig
   map.Resize(headerSize);
   if(fread(&map[0], 1, headerSize, fp) != headerSize)
   {
-    DALI_LOG_WARNING("image file read opeation error!");
+    DALI_LOG_WARNING("image file read opeation error!\n");
     return false;
   }
 
-  if (extractMultiByteInteger(&type, &map[0], fsize, &position) < 0)
+  if (extractMultiByteInteger(&type, &map[0], headerSize, &position) < 0)
   {
-    DALI_LOG_ERROR("Error: unable to read type!");
+    DALI_LOG_ERROR("Error: unable to read type!\n");
     return false;
   }
   position++; /* skipping one byte */
@@ -278,12 +275,12 @@ bool LoadWbmpHeader( const ImageLoader::Input& input, unsigned int& width, unsig
     DALI_LOG_ERROR("Error: unknown format!\n");
     return false;
   }
-  if (extractMultiByteInteger(&w, &map[0], fsize, &position) < 0)
+  if (extractMultiByteInteger(&w, &map[0], headerSize, &position) < 0)
   {
     DALI_LOG_ERROR("Error: can not read width!\n");
     return false;
   }
-  if (extractMultiByteInteger(&h, &map[0], fsize, &position) < 0)
+  if (extractMultiByteInteger(&h, &map[0], headerSize, &position) < 0)
   {
     DALI_LOG_ERROR("Error: can not read height!\n");
     return false;