projects
/
platform
/
core
/
uifw
/
dali-adaptor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix native image capture code and DALi image saving
[platform/core/uifw/dali-adaptor.git]
/
platform-abstractions
/
tizen
/
image-loaders
/
loader-png.cpp
diff --git
a/platform-abstractions/tizen/image-loaders/loader-png.cpp
b/platform-abstractions/tizen/image-loaders/loader-png.cpp
index
d6d6273
..
7d19b56
100644
(file)
--- a/
platform-abstractions/tizen/image-loaders/loader-png.cpp
+++ b/
platform-abstractions/tizen/image-loaders/loader-png.cpp
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 201
4
Samsung Electronics Co., Ltd.
+ * Copyright (c) 201
5
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.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-236,6
+236,13
@@
bool LoadBitmapFromPng( const ResourceLoadingClient& client, const ImageLoader::
{
switch(colordepth)
{
{
switch(colordepth)
{
+ case 1:
+ {
+ pixelFormat = Pixel::LA88;
+ valid = true;
+ break;
+ }
+
case 2:
case 4:
case 8:
case 2:
case 4:
case 8:
@@
-320,7
+327,6
@@
struct AutoPngWrite
: png(_png),
info(_info)
{
: png(_png),
info(_info)
{
- DALI_ASSERT_DEBUG(&_png != 0 && &_info != 0);
}
~AutoPngWrite()
}
~AutoPngWrite()
@@
-347,30
+353,31
@@
namespace
* */
extern "C" void WriteData(png_structp png_ptr, png_bytep data, png_size_t length)
{
* */
extern "C" void WriteData(png_structp png_ptr, png_bytep data, png_size_t length)
{
- using Dali::TizenPlatform::PngBuffer;
DALI_ASSERT_DEBUG(png_ptr && data);
if(!png_ptr || !data)
{
return;
}
// Make sure we don't try to propagate a C++ exception up the call stack of a pure C library:
DALI_ASSERT_DEBUG(png_ptr && data);
if(!png_ptr || !data)
{
return;
}
// Make sure we don't try to propagate a C++ exception up the call stack of a pure C library:
- try {
+ try
+ {
// Recover our buffer for writing into:
// Recover our buffer for writing into:
-
PngBuffer* const encoded_img = (PngBuffer*) png_get_io_ptr(png_ptr
);
+
Vector<unsigned char>* const encoded_img = static_cast< Vector<unsigned char>* >( png_get_io_ptr(png_ptr)
);
if(encoded_img)
{
if(encoded_img)
{
- const
PngBuffer::size_type bufferSize = encoded_img->size
();
- encoded_img->
resize(encoded_img->size() + length
); //< Can throw OOM.
-
PngBuffer::value_type* const bufferBack = &((*encoded_img)[bufferSize])
;
+ const
Vector<unsigned char>::SizeType bufferSize = encoded_img->Count
();
+ encoded_img->
Resize( bufferSize + length
); //< Can throw OOM.
+
unsigned char* const bufferBack = encoded_img->Begin() + bufferSize
;
memcpy(bufferBack, data, length);
}
else
{
memcpy(bufferBack, data, length);
}
else
{
- DALI_LOG_ERROR("PNG buffer for write to memory was passed from libpng as null.");
+ DALI_LOG_ERROR("PNG buffer for write to memory was passed from libpng as null.
\n
");
}
}
- } catch(...)
+ }
+ catch(...)
{
{
- DALI_LOG_ERROR("C++ Exception caught");
+ DALI_LOG_ERROR("C++ Exception caught
\n
");
}
}
}
}
@@
-395,7
+402,7
@@
namespace
* 7. If caller asks for no compression, bypass libpng and blat raw data to
* disk, topped and tailed with header/tail blocks.
*/
* 7. If caller asks for no compression, bypass libpng and blat raw data to
* disk, topped and tailed with header/tail blocks.
*/
-bool EncodeToPng( const unsigned char* const pixelBuffer,
PngBuffer
& encodedPixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat )
+bool EncodeToPng( const unsigned char* const pixelBuffer,
Vector<unsigned char>
& encodedPixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat )
{
// Translate pixel format enum:
int pngPixelFormat = -1;
{
// Translate pixel format enum:
int pngPixelFormat = -1;
@@
-424,7
+431,7
@@
bool EncodeToPng( const unsigned char* const pixelBuffer, PngBuffer& encodedPixe
}
default:
{
}
default:
{
- DALI_LOG_ERROR( "Unsupported pixel format for encoding to PNG." );
+ DALI_LOG_ERROR( "Unsupported pixel format for encoding to PNG.
\n
" );
return false;
}
}
return false;
}
}
@@
-455,7
+462,7
@@
bool EncodeToPng( const unsigned char* const pixelBuffer, PngBuffer& encodedPixe
// Since we are going to write to memory instead of a file, lets provide
// libpng with a custom write function and ask it to pass back our
// Since we are going to write to memory instead of a file, lets provide
// libpng with a custom write function and ask it to pass back our
- //
std::v
ector buffer each time it calls back to flush data to "file":
+ //
V
ector buffer each time it calls back to flush data to "file":
png_set_write_fn(png_ptr, &encodedPixels, WriteData, FlushData);
// png_set_compression_level( png_ptr, Z_BEST_COMPRESSION);
png_set_write_fn(png_ptr, &encodedPixels, WriteData, FlushData);
// png_set_compression_level( png_ptr, Z_BEST_COMPRESSION);