51 def invoke(self, arg, from_tty):
52 frame = gdb.selected_frame()
53 val = frame.read_var(arg)
54 if str(val.type.strip_typedefs()) == 'SkBitmap':
55 pixmap = val['fPixmap']
56 pixels = pixmap['fPixels']
57 row_bytes = pixmap['fRowBytes']
58 info = pixmap['fInfo']
59 dimensions = info['fDimensions']
60 width = dimensions['fWidth']
61 height = dimensions['fHeight']
62 color_type = info['fColorType']
63 alpha_type = info['fAlphaType']
64
65 process = gdb.selected_inferior()
66 memory_data = process.read_memory(pixels, row_bytes * height)
67 size = (width, height)
68 image = None
69
70 if color_type == ColorType.bgra_8888.value:
71 if alpha_type == AlphaType.unpremul.value:
72 image = Image.frombytes("RGBA", size, memory_data,
73 "raw", "BGRA", row_bytes, 1)
74 elif alpha_type == AlphaType.premul.value:
75
76 image = Image.frombytes("RGBA", size, memory_data,
77 "raw", "BGRa", row_bytes, 1)
78
79 if image:
80
81 image.show()
82 else:
83 print ("Need to add support for %s %s." % (
84 str(ColorType(
int(color_type))),
85 str(AlphaType(
int(alpha_type)))
86 ))
87