From: Tom Robinson Date: Thu, 1 Sep 2016 09:40:01 +0000 (+0100) Subject: Debug Patch: Save received indicator images to disk as BMP X-Git-Tag: dali_1.2.8~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5b9e935ab1aed34e211dd267b5075e771cbb3966;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Debug Patch: Save received indicator images to disk as BMP Change-Id: I31c59ae79065be213810642d1b60d497b984e92c --- diff --git a/adaptors/ecore/common/ecore-indicator-impl.cpp b/adaptors/ecore/common/ecore-indicator-impl.cpp index 7d4bb4b9f..746544420 100644 --- a/adaptors/ecore/common/ecore-indicator-impl.cpp +++ b/adaptors/ecore/common/ecore-indicator-impl.cpp @@ -32,12 +32,15 @@ #include #include #include +#include +#include #include #include #include #include #include +#include #include @@ -278,6 +281,59 @@ struct IpcDataEvMouseOut } }; +#ifdef ENABLE_INDICATOR_IMAGE_SAVING + +void SaveIndicatorImage( Dali::NativeImageSourcePtr nativeImageSource ) +{ + // Save image data to disk in BMP form. + static int gFilenameCounter = 0; + static const char bmpHeader[] = { + 0x42, 0x4d, 0x0a, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x7c, 0x00, + 0x00, 0x00, + 0xe0, 0x01, 0x00, 0x00, // Width (480) + 0x1b, 0x00, 0x00, 0x00, // Height ( 27) + 0x01, 0x00, 0x20, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x80, 0xca, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, + 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + // This is a BMP header with width & height hard-coded in. + // The data was first determined by dumping the raw data and inspecting in GIMP, before creating this header data. + std::vector buffer; + unsigned int w = 0; + unsigned int h = 0; + Dali::Pixel::Format pixelFormat; + if( nativeImageSource->GetPixels( buffer, w, h, pixelFormat ) ) + { + int imageSize = w * h * 4; + std::stringstream fileName; + // Give each file an incremental filename. + fileName << "/opt/usr/media/Images/out-" << std::setfill( '0' ) << std::setw( 5 ) << gFilenameCounter << ".bmp"; + + std::ofstream outfile( fileName.str().c_str(), std::ofstream::binary ); + if( outfile.is_open() ) + { + DALI_LOG_WARNING( "Saving Indicator Image w:%d, h:%d, %s\n", w, h, fileName.str().c_str() ); + + outfile.write( bmpHeader, sizeof( bmpHeader ) / sizeof( bmpHeader[0] ) ); // Size of the BMP header. + outfile.write( (const char*)buffer.data(), imageSize ); + outfile.close(); + gFilenameCounter++; + } + else + { + DALI_LOG_ERROR( "COULD NOT OPEN FOR SAVING: %s\n", fileName.str().c_str() ); + } + } +} + +#endif + } // anonymous namespace @@ -1088,6 +1144,10 @@ void Indicator::CreateNewPixmapImage() DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "W:%d H:%d", mImageWidth, mImageHeight ); Dali::NativeImageSourcePtr nativeImageSource = Dali::NativeImageSource::New( mPixmap ); +#ifdef ENABLE_INDICATOR_IMAGE_SAVING + SaveIndicatorImage( nativeImageSource ); +#endif + if( nativeImageSource ) { Dali::Texture texture = Dali::Texture::New( *nativeImageSource );