{"id":58,"date":"2026-07-21T05:49:41","date_gmt":"2026-07-21T05:49:41","guid":{"rendered":"https:\/\/blogs.scummvm.org\/priyanshu\/?p=58"},"modified":"2026-07-21T05:55:04","modified_gmt":"2026-07-21T05:55:04","slug":"week-9","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/priyanshu\/2026\/07\/21\/week-9\/","title":{"rendered":"Week 9"},"content":{"rendered":"<p>As I mentioned in the last week&#8217;s blog, the game assets have CgBI PNGs in it which we need to decode.<\/p>\n<p>Initially, I thought about converting it to a standard PNG to have the PNGDecoder decode it but since we have the raw pixels extracted, we can just draw the surface.<\/p>\n<h4>How different is the CgBI format than standard PNG<\/h4>\n<p>Apple had created this format to optimize for the native pixel format of the iPhone&#8217;s early PowerVR GPUs. It contains significant differences like-<\/p>\n<ul>\n<li>An extra critical chunk(CgBI) &#8211; Right after the 8 byte standard PNG header and 4 bytes for length, CgBI format has also a CgBI type field from bytes 12-15.<\/li>\n<li>Swapped pixel format &#8211; Instead of a standard PNG file&#8217;s pixel format, i.e., RGBA, CgBI format has the pixel format swapped to BGRA. The red and the blue channel are swapped, presumably for high speed direct blitting to the framebuffer.<\/li>\n<li>It contains raw deflate data. It has the zlib header, footer removed from the IDAT chunk.<\/li>\n<li>It has every channel pre-multiplied with the alpha channel.<\/li>\n<li>Pre-multiplied with the alpha channel during encoding: color&#8217; = color * alpha \/ 255<\/li>\n<\/ul>\n<p>I have extracted the raw pixels by removing the CgBI header, un-premultiplying the alpha channel and swapping the red and blue channel all while working on raw deflate data. Next, I will be drawing the surface and we&#8217;ll have the help window displayed on our screen. The immediate next step after that would be to render the help contents on it. Hopefully, I will be briefing about that in the next blog \ud83d\ude09<\/p>\n<p>Thanks for reading \ud83d\ude42<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As I mentioned in the last week&#8217;s blog, the game assets have CgBI PNGs in it which we need to decode. Initially, I thought about converting it to a standard PNG to have the PNGDecoder decode it but since we have the raw pixels extracted, we can just draw the surface. How different is the [&hellip;]<\/p>\n","protected":false},"author":33,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-58","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/priyanshu\/wp-json\/wp\/v2\/posts\/58","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/priyanshu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/priyanshu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/priyanshu\/wp-json\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/priyanshu\/wp-json\/wp\/v2\/comments?post=58"}],"version-history":[{"count":3,"href":"https:\/\/blogs.scummvm.org\/priyanshu\/wp-json\/wp\/v2\/posts\/58\/revisions"}],"predecessor-version":[{"id":62,"href":"https:\/\/blogs.scummvm.org\/priyanshu\/wp-json\/wp\/v2\/posts\/58\/revisions\/62"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/priyanshu\/wp-json\/wp\/v2\/media?parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/priyanshu\/wp-json\/wp\/v2\/categories?post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/priyanshu\/wp-json\/wp\/v2\/tags?post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}