{"id":15,"date":"2016-06-02T14:01:00","date_gmt":"2016-06-02T12:01:00","guid":{"rendered":"https:\/\/blogs.scummvm.org\/blorente\/?p=15"},"modified":"2022-04-15T13:07:00","modified_gmt":"2022-04-15T11:07:00","slug":"9-patches-to-my-heart","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/blorente\/2016\/06\/02\/9-patches-to-my-heart\/","title":{"rendered":"9 Patches to my heart"},"content":{"rendered":"\n<p>For the better part of this week and past weekend, I have been learing a whole lot about surfaces in ScummVM, in order to implement beautiful 9patch borders in the MacGUI code.<\/p>\n\n\n\n<p>As I delved deeper and deeper into the graphics code, I found out that a lot of steps had to be made in order for the 9patch to initialize and blit correctly:<\/p>\n\n\n\n<!--more-->\n\n\n\n<ol class=\"wp-block-list\"><li>Define the alpha color in a bitmap (a bright pink).<\/li><li>Load the bitmap.<\/li><li>Copy the loaded bitmap into a surface.<\/li><li>Apply the colorkey into the surface (previously defined alpha color).<\/li><li>Pass the surface to the 9patch.<\/li><li>Define the surface in which you want to blit the border.<\/li><li>Blit the border.<\/li><li>Convert the border into the graphics format (I still don\u2019t know how to do this).<\/li><li>Draw the border into the surface you want.<\/li><li>Tell <a href=\"https:\/\/web.archive.org\/web\/20200426204825\/https:\/\/t.umblr.com\/redirect?z=http%3A%2F%2Fwiki.scummvm.org%2Findex.php%2FUser%3ASev&amp;t=MjRhYTA4NjZhZjgyMTdmMzc5YjIwNzg5MDBlZGI5MDFiMDk0YTg3YSxjNXM3ZmdnRg%3D%3D&amp;b=t%3A1B-6m0r5fRzyZAKM79LNMg&amp;p=https%3A%2F%2Fblorente.tumblr.com%2Fpost%2F145306134292%2F9-patches-to-my-heart&amp;m=1\" target=\"_blank\" rel=\"noopener\">sev<\/a> that you finally got his code to work, and that it works wonders.<\/li><\/ol>\n\n\n\n<p>Between each of these steps there are several hours of figuring out which <code>PixelFormats<\/code>, <code>Palettes<\/code>, <code>Surfaces<\/code> and conversion functions I had to use, and several more hours in GDB and the IRC.<\/p>\n\n\n\n<p>But, at last, besides that format conversion in step 8, 9patch is working correctly \ud83d\ude42<\/p>\n\n\n\n<p>Below are two images: The border bitmap rendered <i>without<\/i> going through the 9patch, and after passing it to the 9patch and <i>then<\/i> rendering (blit) it into surface twice as high and wide (4x size) before printing it to screen.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/blogs.scummvm.org\/blorente\/wp-content\/uploads\/sites\/15\/2022\/04\/1.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"523\" height=\"355\" src=\"https:\/\/blogs.scummvm.org\/blorente\/wp-content\/uploads\/sites\/15\/2022\/04\/1.jpg\" alt=\"\" class=\"wp-image-16\" srcset=\"https:\/\/blogs.scummvm.org\/blorente\/wp-content\/uploads\/sites\/15\/2022\/04\/1.jpg 523w, https:\/\/blogs.scummvm.org\/blorente\/wp-content\/uploads\/sites\/15\/2022\/04\/1-300x204.jpg 300w\" sizes=\"auto, (max-width: 523px) 100vw, 523px\" \/><\/a><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/blogs.scummvm.org\/blorente\/wp-content\/uploads\/sites\/15\/2022\/04\/2.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"515\" height=\"348\" src=\"https:\/\/blogs.scummvm.org\/blorente\/wp-content\/uploads\/sites\/15\/2022\/04\/2.jpg\" alt=\"\" class=\"wp-image-17\" srcset=\"https:\/\/blogs.scummvm.org\/blorente\/wp-content\/uploads\/sites\/15\/2022\/04\/2.jpg 515w, https:\/\/blogs.scummvm.org\/blorente\/wp-content\/uploads\/sites\/15\/2022\/04\/2-300x203.jpg 300w\" sizes=\"auto, (max-width: 515px) 100vw, 515px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>Edit: I just fixed a small bug, this is what it looks like now:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/blogs.scummvm.org\/blorente\/wp-content\/uploads\/sites\/15\/2022\/04\/3.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"670\" height=\"416\" src=\"https:\/\/blogs.scummvm.org\/blorente\/wp-content\/uploads\/sites\/15\/2022\/04\/3.jpg\" alt=\"\" class=\"wp-image-18\" srcset=\"https:\/\/blogs.scummvm.org\/blorente\/wp-content\/uploads\/sites\/15\/2022\/04\/3.jpg 670w, https:\/\/blogs.scummvm.org\/blorente\/wp-content\/uploads\/sites\/15\/2022\/04\/3-300x186.jpg 300w\" sizes=\"auto, (max-width: 670px) 100vw, 670px\" \/><\/a><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>For the better part of this week and past weekend, I have been learing a whole lot about surfaces in ScummVM, in order to implement beautiful 9patch borders in the MacGUI code. As I delved deeper and deeper into the graphics code, I found out that a lot of steps had to be made in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-15","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/blorente\/wp-json\/wp\/v2\/posts\/15","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/blorente\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/blorente\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/blorente\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/blorente\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":2,"href":"https:\/\/blogs.scummvm.org\/blorente\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"predecessor-version":[{"id":76,"href":"https:\/\/blogs.scummvm.org\/blorente\/wp-json\/wp\/v2\/posts\/15\/revisions\/76"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/blorente\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/blorente\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/blorente\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}