| 1207 | } |
| 1208 | |
| 1209 | bool gpu_image::unpack(image& img) const |
| 1210 | { |
| 1211 | img.resize(get_pixel_width(), get_pixel_height()); |
| 1212 | img.set_all(g_black_color); |
| 1213 | |
| 1214 | if (!img.get_width() || !img.get_height()) |
| 1215 | return true; |
| 1216 | |
| 1217 | if ((m_fmt == texture_format::cPVRTC1_4_RGB) || (m_fmt == texture_format::cPVRTC1_4_RGBA)) |
| 1218 | { |
| 1219 | pvrtc4_image pi(m_width, m_height); |
| 1220 | |
| 1221 | if (get_total_blocks() != pi.get_total_blocks()) |
| 1222 | return false; |
| 1223 | |
| 1224 | memcpy(&pi.get_blocks()[0], get_ptr(), get_size_in_bytes()); |
| 1225 | |
| 1226 | pi.deswizzle(); |
| 1227 | |
| 1228 | pi.unpack_all_pixels(img); |
| 1229 | |
| 1230 | return true; |
| 1231 | } |
| 1232 | |
| 1233 | assert((m_block_width <= cMaxBlockSize) && (m_block_height <= cMaxBlockSize)); |
| 1234 | color_rgba pixels[cMaxBlockSize * cMaxBlockSize]; |
| 1235 | for (uint32_t i = 0; i < cMaxBlockSize * cMaxBlockSize; i++) |
| 1236 | pixels[i] = g_black_color; |
| 1237 | |
| 1238 | bool success = true; |
| 1239 | |
| 1240 | for (uint32_t by = 0; by < m_blocks_y; by++) |
| 1241 | { |
| 1242 | for (uint32_t bx = 0; bx < m_blocks_x; bx++) |
| 1243 | { |
| 1244 | const void* pBlock = get_block_ptr(bx, by); |
| 1245 | |
| 1246 | if (!unpack_block(m_fmt, pBlock, pixels)) |
| 1247 | success = false; |
| 1248 | |
| 1249 | img.set_block_clipped(pixels, bx * m_block_width, by * m_block_height, m_block_width, m_block_height); |
| 1250 | } // bx |
| 1251 | } // by |
| 1252 | |
| 1253 | return success; |
| 1254 | } |
| 1255 | |
| 1256 | static const uint8_t g_ktx_file_id[12] = { 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A }; |
| 1257 |
no test coverage detected