Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
bitmap.sk_bitmap Class Reference
Inheritance diagram for bitmap.sk_bitmap:

Public Member Functions

 __init__ (self)
 
 invoke (self, arg, from_tty)
 

Detailed Description

Displays the content of an SkBitmap image.

Definition at line 43 of file bitmap.py.

Constructor & Destructor Documentation

◆ __init__()

bitmap.sk_bitmap.__init__ (   self)

Definition at line 46 of file bitmap.py.

46 def __init__(self):
47 super(sk_bitmap, self).__init__('sk_bitmap',
48 gdb.COMMAND_SUPPORT,
49 gdb.COMPLETE_FILENAME)
50

Member Function Documentation

◆ invoke()

bitmap.sk_bitmap.invoke (   self,
  arg,
  from_tty 
)

Definition at line 51 of file bitmap.py.

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 # See Unpack.c for the values understood after the "raw" parameter.
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 # RGBA instead of RGBa, because Image.show() doesn't work with RGBa.
76 image = Image.frombytes("RGBA", size, memory_data,
77 "raw", "BGRa", row_bytes, 1)
78
79 if image:
80 # Fails on premultiplied alpha, it cannot convert to RGB.
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
Type::kYUV Type::kRGBA() int(0.7 *637)

The documentation for this class was generated from the following file: