2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "loader-ktx.h"
23 #include <dali/public-api/common/compile-time-assert.h>
24 #include <dali/integration-api/debug.h>
25 #include <adaptors/devel-api/adaptor-framework/pixel-buffer.h>
30 namespace TizenPlatform
36 /** Max width or height of an image. */
37 const unsigned MAX_TEXTURE_DIMENSION = 4096;
38 /** Max bytes of image data allowed. Not a precise number, just a sanity check. */
39 const unsigned MAX_IMAGE_DATA_SIZE = MAX_TEXTURE_DIMENSION * MAX_TEXTURE_DIMENSION;
40 /** We don't read any of this but limit it to a resonable amount in order to be
41 * friendly to files from random tools. */
42 const unsigned MAX_BYTES_OF_KEYVALUE_DATA = 65536U;
46 const Byte FileIdentifier[] = {
47 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
51 /** The formats we support inside a KTX file container.
52 * Currently only compressed formats are allowed as we'd rather
53 * use a PNG or JPEG with their own compression for the general
55 enum KtxInternalFormat
59 // GLES 2 Extension formats:
60 KTX_ETC1_RGB8_OES = 0x8D64,
61 KTX_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00,
63 // GLES 3 Standard compressed formats (values same as in gl3.h):
64 KTX_COMPRESSED_R11_EAC = 0x9270,
65 KTX_COMPRESSED_SIGNED_R11_EAC = 0x9271,
66 KTX_COMPRESSED_RG11_EAC = 0x9272,
67 KTX_COMPRESSED_SIGNED_RG11_EAC = 0x9273,
68 KTX_COMPRESSED_RGB8_ETC2 = 0x9274,
69 KTX_COMPRESSED_SRGB8_ETC2 = 0x9275,
70 KTX_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276,
71 KTX_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277,
72 KTX_COMPRESSED_RGBA8_ETC2_EAC = 0x9278,
73 KTX_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279,
75 // GLES 3.1 compressed formats:
76 KTX_COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0,
77 KTX_COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93B1,
78 KTX_COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93B2,
79 KTX_COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93B3,
80 KTX_COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93B4,
81 KTX_COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93B5,
82 KTX_COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93B6,
83 KTX_COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93B7,
84 KTX_COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93B8,
85 KTX_COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93B9,
86 KTX_COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93BA,
87 KTX_COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93BB,
88 KTX_COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93BC,
89 KTX_COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93BD,
90 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93D0,
91 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93D1,
92 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93D2,
93 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93D3,
94 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93D4,
95 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93D5,
96 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93D6,
97 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93D7,
98 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93D8,
99 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93D9,
100 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93DA,
101 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93DB,
102 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93DC,
103 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93DD,
105 // Uncompressed Alpha format
106 KTX_UNCOMPRESSED_ALPHA8 = 0x1906,
111 const unsigned KtxInternalFormats[] =
113 // GLES 2 Extension formats:
115 KTX_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
117 // GLES 3 Standard compressed formats:
118 KTX_COMPRESSED_R11_EAC,
119 KTX_COMPRESSED_SIGNED_R11_EAC,
120 KTX_COMPRESSED_RG11_EAC,
121 KTX_COMPRESSED_SIGNED_RG11_EAC,
122 KTX_COMPRESSED_RGB8_ETC2,
123 KTX_COMPRESSED_SRGB8_ETC2,
124 KTX_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
125 KTX_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
126 KTX_COMPRESSED_RGBA8_ETC2_EAC,
127 KTX_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
129 // GLES 3.1 Compressed formats:
130 KTX_COMPRESSED_RGBA_ASTC_4x4_KHR,
131 KTX_COMPRESSED_RGBA_ASTC_5x4_KHR,
132 KTX_COMPRESSED_RGBA_ASTC_5x5_KHR,
133 KTX_COMPRESSED_RGBA_ASTC_6x5_KHR,
134 KTX_COMPRESSED_RGBA_ASTC_6x6_KHR,
135 KTX_COMPRESSED_RGBA_ASTC_8x5_KHR,
136 KTX_COMPRESSED_RGBA_ASTC_8x6_KHR,
137 KTX_COMPRESSED_RGBA_ASTC_8x8_KHR,
138 KTX_COMPRESSED_RGBA_ASTC_10x5_KHR,
139 KTX_COMPRESSED_RGBA_ASTC_10x6_KHR,
140 KTX_COMPRESSED_RGBA_ASTC_10x8_KHR,
141 KTX_COMPRESSED_RGBA_ASTC_10x10_KHR,
142 KTX_COMPRESSED_RGBA_ASTC_12x10_KHR,
143 KTX_COMPRESSED_RGBA_ASTC_12x12_KHR,
144 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
145 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
146 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
147 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
148 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
149 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
150 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
151 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
152 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
153 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
154 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
155 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
156 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
157 KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
159 // Uncompressed Alpha format
160 KTX_UNCOMPRESSED_ALPHA8,
172 uint32_t glInternalFormat;
173 uint32_t glBaseInternalFormat;
175 uint32_t pixelHeight;
177 uint32_t numberOfArrayElements;
178 uint32_t numberOfFaces;
179 uint32_t numberOfMipmapLevels;
180 uint32_t bytesOfKeyValueData;
181 } __attribute__ ( (__packed__));
182 // Packed attribute stops the structure from being aligned to compiler defaults
183 // so we can be sure of reading the whole thing from file in one call to fread.
186 * Function to read from the file directly into our structure.
187 * @param[in] fp The file to read from
188 * @param[out] header The structure we want to store our information in
189 * @return true, if read successful, false otherwise
191 inline bool ReadHeader( FILE* filePointer, KtxFileHeader& header )
193 const unsigned int readLength = sizeof( KtxFileHeader );
195 // Load the information directly into our structure
196 if( fread( &header, 1, readLength, filePointer ) != readLength )
204 /** Check whether the array passed in is the right size and matches the magic
205 * values defined to be at the start of a KTX file by the specification.*/
206 template<int BYTES_IN_SIGNATURE>
207 bool CheckFileIdentifier(const Byte * const signature)
209 const unsigned signatureSize = BYTES_IN_SIGNATURE;
210 const unsigned identifierSize = sizeof(FileIdentifier);
211 DALI_COMPILE_TIME_ASSERT(signatureSize == identifierSize);
212 const bool signatureGood = 0 == memcmp( signature, FileIdentifier, std::min( signatureSize, identifierSize ) );
213 return signatureGood;
217 * @returns True if the argument is a GLES compressed texture format that we support.
219 bool ValidInternalFormat(const unsigned format)
221 unsigned candidateFormat = 0;
222 for(unsigned iFormat = 0; (candidateFormat = KtxInternalFormats[iFormat]) != KTX_SENTINEL; ++iFormat)
224 if(format == candidateFormat)
229 DALI_LOG_ERROR("Rejecting unsupported compressed format when loading compressed texture from KTX file: 0x%x.\n", format);
234 * @returns The Pixel::Format Dali enum corresponding to the KTX internal format
235 * passed in, or Pixel::INVALID_PIXEL_FORMAT if the format is not valid.
237 bool ConvertPixelFormat(const uint32_t ktxPixelFormat, Dali::Pixel::Format& format)
239 using namespace Dali::Pixel;
240 switch(ktxPixelFormat)
242 // GLES 2 extension compressed formats:
243 case KTX_ETC1_RGB8_OES:
245 format = COMPRESSED_RGB8_ETC1;
248 case KTX_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
250 format = COMPRESSED_RGB_PVRTC_4BPPV1;
254 // GLES 3 extension compressed formats:
255 case KTX_COMPRESSED_R11_EAC:
257 format = COMPRESSED_R11_EAC;
260 case KTX_COMPRESSED_SIGNED_R11_EAC:
262 format = COMPRESSED_SIGNED_R11_EAC;
265 case KTX_COMPRESSED_RG11_EAC:
267 format = COMPRESSED_RG11_EAC;
270 case KTX_COMPRESSED_SIGNED_RG11_EAC:
272 format = COMPRESSED_SIGNED_RG11_EAC;
275 case KTX_COMPRESSED_RGB8_ETC2:
277 format = COMPRESSED_RGB8_ETC2;
280 case KTX_COMPRESSED_SRGB8_ETC2:
282 format = COMPRESSED_SRGB8_ETC2;
285 case KTX_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
287 format = COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
290 case KTX_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
292 format = COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;
295 case KTX_COMPRESSED_RGBA8_ETC2_EAC:
297 format = COMPRESSED_RGBA8_ETC2_EAC;
300 case KTX_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
302 format = COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
306 // GLES 3.1 extension compressed formats:
307 case KTX_COMPRESSED_RGBA_ASTC_4x4_KHR:
309 format = COMPRESSED_RGBA_ASTC_4x4_KHR;
312 case KTX_COMPRESSED_RGBA_ASTC_5x4_KHR:
314 format = COMPRESSED_RGBA_ASTC_5x4_KHR;
317 case KTX_COMPRESSED_RGBA_ASTC_5x5_KHR:
319 format = COMPRESSED_RGBA_ASTC_5x5_KHR;
322 case KTX_COMPRESSED_RGBA_ASTC_6x5_KHR:
324 format = COMPRESSED_RGBA_ASTC_6x5_KHR;
327 case KTX_COMPRESSED_RGBA_ASTC_6x6_KHR:
329 format = COMPRESSED_RGBA_ASTC_6x6_KHR;
332 case KTX_COMPRESSED_RGBA_ASTC_8x5_KHR:
334 format = COMPRESSED_RGBA_ASTC_8x5_KHR;
337 case KTX_COMPRESSED_RGBA_ASTC_8x6_KHR:
339 format = COMPRESSED_RGBA_ASTC_8x6_KHR;
342 case KTX_COMPRESSED_RGBA_ASTC_8x8_KHR:
344 format = COMPRESSED_RGBA_ASTC_8x8_KHR;
347 case KTX_COMPRESSED_RGBA_ASTC_10x5_KHR:
349 format = COMPRESSED_RGBA_ASTC_10x5_KHR;
352 case KTX_COMPRESSED_RGBA_ASTC_10x6_KHR:
354 format = COMPRESSED_RGBA_ASTC_10x6_KHR;
357 case KTX_COMPRESSED_RGBA_ASTC_10x8_KHR:
359 format = COMPRESSED_RGBA_ASTC_10x8_KHR;
362 case KTX_COMPRESSED_RGBA_ASTC_10x10_KHR:
364 format = COMPRESSED_RGBA_ASTC_10x10_KHR;
367 case KTX_COMPRESSED_RGBA_ASTC_12x10_KHR:
369 format = COMPRESSED_RGBA_ASTC_12x10_KHR;
372 case KTX_COMPRESSED_RGBA_ASTC_12x12_KHR:
374 format = COMPRESSED_RGBA_ASTC_12x12_KHR;
377 case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
379 format = COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
382 case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:
384 format = COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;
387 case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:
389 format = COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;
392 case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:
394 format = COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;
397 case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:
399 format = COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;
402 case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:
404 format = COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;
407 case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:
409 format = COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;
412 case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:
414 format = COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;
417 case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:
419 format = COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;
422 case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:
424 format = COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;
427 case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:
429 format = COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;
432 case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
434 format = COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;
437 case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
439 format = COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;
442 case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
444 format = COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;
448 // Uncompressed Alpha format
449 case KTX_UNCOMPRESSED_ALPHA8:
463 bool LoadKtxHeader( FILE * const fp, unsigned int& width, unsigned int& height, KtxFileHeader& fileHeader )
465 // Pull the bytes of the file header in as a block:
466 if ( !ReadHeader( fp, fileHeader ) )
470 width = fileHeader.pixelWidth;
471 height = fileHeader.pixelHeight;
473 if ( width > MAX_TEXTURE_DIMENSION || height > MAX_TEXTURE_DIMENSION )
478 // Validate file header contents meet our minimal subset:
479 const bool signatureGood = CheckFileIdentifier<sizeof(fileHeader.identifier)>(fileHeader.identifier);
480 const bool fileEndiannessMatchesSystemEndianness = fileHeader.endianness == 0x04030201; // Magic number from KTX spec.
481 const bool glTypeIsCompressed = fileHeader.glType == 0;
482 const bool glTypeSizeCompatibleWithCompressedTex = fileHeader.glTypeSize == 1;
483 const bool glFormatCompatibleWithCompressedTex = fileHeader.glFormat == 0;
484 const bool glInternalFormatIsSupportedCompressedTex = ValidInternalFormat(fileHeader.glInternalFormat);
485 // Ignore glBaseInternalFormat
486 const bool textureIsNot3D = fileHeader.pixelDepth == 0 || fileHeader.pixelDepth == 1;
487 const bool textureIsNotAnArray = fileHeader.numberOfArrayElements == 0 || fileHeader.numberOfArrayElements == 1;
488 const bool textureIsNotACubemap = fileHeader.numberOfFaces == 0 || fileHeader.numberOfFaces == 1;
489 const bool textureHasNoMipmapLevels = fileHeader.numberOfMipmapLevels == 0 || fileHeader.numberOfMipmapLevels == 1;
490 const bool keyValueDataNotTooLarge = fileHeader.bytesOfKeyValueData <= MAX_BYTES_OF_KEYVALUE_DATA;
492 bool headerIsValid = signatureGood && fileEndiannessMatchesSystemEndianness &&
493 glTypeSizeCompatibleWithCompressedTex && textureIsNot3D && textureIsNotAnArray &&
494 textureIsNotACubemap && textureHasNoMipmapLevels && keyValueDataNotTooLarge;
496 if( !glTypeIsCompressed ) // check for uncompressed Alpha
498 const bool isAlpha = ( ( fileHeader.glBaseInternalFormat == KTX_UNCOMPRESSED_ALPHA8 ) && ( fileHeader.glFormat == KTX_UNCOMPRESSED_ALPHA8 ) &&
499 ( fileHeader.glInternalFormat == KTX_UNCOMPRESSED_ALPHA8 ) );
500 headerIsValid = headerIsValid && isAlpha;
504 headerIsValid = headerIsValid && glFormatCompatibleWithCompressedTex && glInternalFormatIsSupportedCompressedTex;
509 DALI_LOG_ERROR( "KTX file invalid or using unsupported features. Header tests: sig: %d, endian: %d, gl_type: %d, gl_type_size: %d, gl_format: %d, internal_format: %d, depth: %d, array: %d, faces: %d, mipmap: %d, vey-vals: %d.\n", 0+signatureGood, 0+fileEndiannessMatchesSystemEndianness, 0+glTypeIsCompressed, 0+glTypeSizeCompatibleWithCompressedTex, 0+glFormatCompatibleWithCompressedTex, 0+glInternalFormatIsSupportedCompressedTex, 0+textureIsNot3D, 0+textureIsNotAnArray, 0+textureIsNotACubemap, 0+textureHasNoMipmapLevels, 0+keyValueDataNotTooLarge);
512 // Warn if there is space wasted in the file:
513 if( fileHeader.bytesOfKeyValueData > 0U )
515 DALI_LOG_WARNING("Loading of KTX file with key/value header data requested. This should be stripped in application asset/resource build.\n");
518 return headerIsValid;
522 } // unnamed namespace
524 // File loading API entry-point:
525 bool LoadKtxHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height )
527 KtxFileHeader fileHeader;
528 FILE* const fp = input.file;
530 bool ret = LoadKtxHeader(fp, width, height, fileHeader);
534 // File loading API entry-point:
535 bool LoadBitmapFromKtx( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
537 DALI_COMPILE_TIME_ASSERT( sizeof(Byte) == 1);
538 DALI_COMPILE_TIME_ASSERT( sizeof(uint32_t) == 4);
540 FILE* const fp = input.file;
543 DALI_LOG_ERROR( "Null file handle passed to KTX compressed bitmap file loader.\n" );
546 KtxFileHeader fileHeader;
548 // Load the header info
549 unsigned int width, height;
551 if (!LoadKtxHeader(fp, width, height, fileHeader))
556 // Skip the key-values:
557 const long int imageSizeOffset = sizeof(KtxFileHeader) + fileHeader.bytesOfKeyValueData;
558 if(fseek(fp, imageSizeOffset, SEEK_SET))
560 DALI_LOG_ERROR( "Seek past key/vals in KTX compressed bitmap file failed.\n" );
564 // Load the size of the image data:
565 uint32_t imageByteCount = 0;
566 if ( fread( &imageByteCount, 1, 4, fp ) != 4 )
568 DALI_LOG_ERROR( "Read of image size failed.\n" );
571 // Sanity-check the image size:
572 if( imageByteCount > MAX_IMAGE_DATA_SIZE ||
573 // A compressed texture should certainly be less than 2 bytes per texel:
574 imageByteCount > width * height * 2)
576 DALI_LOG_ERROR( "KTX file with too-large image-data field.\n" );
580 Pixel::Format pixelFormat;
581 const bool pixelFormatKnown = ConvertPixelFormat(fileHeader.glInternalFormat, pixelFormat);
582 if(!pixelFormatKnown)
584 DALI_LOG_ERROR( "No internal pixel format supported for KTX file pixel format.\n" );
588 // Load up the image bytes:
589 bitmap = Dali::Devel::PixelBuffer::New(width, height, pixelFormat);
590 auto pixels = bitmap.GetBuffer();
594 DALI_LOG_ERROR( "Unable to reserve a pixel buffer to load the requested bitmap into.\n" );
597 const size_t bytesRead = fread(pixels, 1, imageByteCount, fp);
598 if(bytesRead != imageByteCount)
600 DALI_LOG_ERROR( "Read of image pixel data failed.\n" );
607 } // namespace TizenPlatform