Mercurial > repos > ghero
comparison img2dcolor.py @ 12:580b64af2241
Add support for images that have already had their width cut down in direct color converter. Remove debug print statement.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 06 Sep 2013 19:13:46 -0700 |
parents | 19226d79f839 |
children |
comparison
equal
deleted
inserted
replaced
11:19226d79f839 | 12:580b64af2241 |
---|---|
16 (width, height) = im.size | 16 (width, height) = im.size |
17 gpixels = bytearray() | 17 gpixels = bytearray() |
18 A = 255 | 18 A = 255 |
19 x = 0 | 19 x = 0 |
20 y = 0 | 20 y = 0 |
21 out_width = width if width <= 198 else width/2 | |
21 for pixel in pixels: | 22 for pixel in pixels: |
22 if x == width: | 23 if x == width: |
23 x = 0 | 24 x = 0 |
24 y += 1 | 25 y += 1 |
25 if x == 0: | 26 if x == 0: |
26 pad = 198-width/2 | 27 pad = 198-out_width |
27 print 'pad', pad | |
28 for i in xrange(0, pad*2): | 28 for i in xrange(0, pad*2): |
29 gpixels.append(0) | 29 gpixels.append(0) |
30 if not (x & 1): | 30 if width == out_width or not (x & 1): |
31 (R,G,B) = gcolor(pixel) | 31 (R,G,B) = gcolor(pixel) |
32 gpixels.append(B) | 32 gpixels.append(B) |
33 gpixels.append(G << 4 | R) | 33 gpixels.append(G << 4 | R) |
34 x += 1 | 34 x += 1 |
35 return gpixels | 35 return gpixels |