<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: bitmap code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 04:30:32 GMT</pubDate>
    <description>DZone Snippets: bitmap code</description>
    <item>
      <title>Compare two bitmap objects</title>
      <link>http://snippets.dzone.com/posts/show/3883</link>
      <description>&lt;code&gt;&lt;br /&gt;        private bool PicsIdentical(Bitmap bmp1, Bitmap bmp2)&lt;br /&gt;        {&lt;br /&gt;            bool retVal = true;&lt;br /&gt;&lt;br /&gt;            if (bmp1.Size != bmp2.Size)&lt;br /&gt;                retVal = false;&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                for (int x = 0; x &lt; bmp1.Width; x++)&lt;br /&gt;                {&lt;br /&gt;                    for (int y = 0; y &lt; bmp1.Height; y++)&lt;br /&gt;                    {&lt;br /&gt;                        if (bmp1.GetPixel(x, y) != bmp2.GetPixel(x, y))&lt;br /&gt;                        {&lt;br /&gt;                            retVal = false;&lt;br /&gt;                            break;&lt;br /&gt;                        }&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            return retVal;&lt;br /&gt;        }&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 24 Apr 2007 22:34:24 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3883</guid>
      <author>mstampar (Miroslav Stampar)</author>
    </item>
    <item>
      <title>Counting number of bitmaps in an mbm file</title>
      <link>http://snippets.dzone.com/posts/show/1472</link>
      <description>I continue &lt;a href=http://discussion.forum.nokia.com/forum/showthread.php?t=63608&gt;my hacking&lt;/a&gt; on symbian mbm(multi-bitmap) format.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# a helping function&lt;br /&gt;from struct import unpack&lt;br /&gt;def readL(f, pos=None):&lt;br /&gt;    if pos is not None:&lt;br /&gt;        f.seek(pos)&lt;br /&gt;    return unpack('L', f.read(4))[0]&lt;br /&gt;&lt;br /&gt;# the real counting function&lt;br /&gt;def mbm_count(mbm_file):&lt;br /&gt;    f = open(mbm_file, 'rb')&lt;br /&gt;    mbm_type = readL(f)&lt;br /&gt;    if mbm_type == 0x10000041:  # mbm on ROM (Z:)&lt;br /&gt;        return readL(f) &lt;br /&gt;    elif mbm_type == 0x10000037L:  # mbm on file (normal)&lt;br /&gt;        return readL(f, readL(f, 16)) # read at trailer&lt;br /&gt;    else:       # what type is it?&lt;br /&gt;        return None&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;For example (you may try this on your phone)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&gt;&gt;&gt; mbm_count('z:\\system\\data\\avkon.mbm')&lt;br /&gt;503L&lt;br /&gt;&gt;&gt;&gt; mbm_count('E:\\system\\apps\\FExplorer\\FExplorer.mbm')&lt;br /&gt;19L&lt;br /&gt;&gt;&gt;&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Mon, 13 Feb 2006 22:32:04 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1472</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>Using Icon as Image</title>
      <link>http://snippets.dzone.com/posts/show/445</link>
      <description>Pys60 1.1.3 have 2 differnt classes for graphics data.&lt;br /&gt;Icon class represents icon (typically from .mbm file)&lt;br /&gt;which can be put in ListBox for selection.&lt;br /&gt;Image class represents a bigger image which can be&lt;br /&gt;drawn upon. These 2 classes can't convert to/from&lt;br /&gt;each other.&lt;br /&gt;&lt;br /&gt;So, I create a library that read .mbm file and draw&lt;br /&gt;an Image from the data there. So, you can make&lt;br /&gt;an icon into an image (now only 1-bit icons).&lt;br /&gt;the module can be downloaded from here&lt;br /&gt;http://larndham.net/service/pys60/icon_image.py&lt;br /&gt;&lt;code&gt;&lt;br /&gt;from appuifw import *&lt;br /&gt;import icon_image, e32&lt;br /&gt;&lt;br /&gt;app.body = c = Canvas()&lt;br /&gt;# choose a bitmap from plenty inside mbm (multi-bitmap)&lt;br /&gt;icon = icon_image('z:\\system\\data\\avkon.mbm', 28) &lt;br /&gt;c.blit(icon)&lt;br /&gt;&lt;br /&gt;e32.ao_sleep(10)  # 10 sec to end program&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Look here for more information.&lt;br /&gt;http://discussion.forum.nokia.com/forum/showthread.php?s=&amp;threadid=63608</description>
      <pubDate>Sun, 03 Jul 2005 02:02:10 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/445</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
