uiautomation
uiautomation.uiautomation.Bitmap クラス

公開メンバ関数

def __init__ (self, int width=0, int height=0)
 
def __del__ (self)
 
None Release (self)
 
int Width (self)
 
int Height (self)
 
bool FromHandle (self, int hwnd, int left=0, int top=0, int right=0, int bottom=0)
 
bool FromControl (self, 'Control' control, int x=0, int y=0, int width=0, int height=0)
 
bool FromFile (self, str filePath)
 
bool ToFile (self, str savePath)
 
int GetPixelColor (self, int x, int y)
 
bool SetPixelColor (self, int x, int y, int argb)
 
ctypes.Array GetPixelColorsHorizontally (self, int x, int y, int count)
 
bool SetPixelColorsHorizontally (self, int x, int y, Iterable[int] colors)
 
ctypes.Array GetPixelColorsVertically (self, int x, int y, int count)
 
bool SetPixelColorsVertically (self, int x, int y, Iterable[int] colors)
 
ctypes.Array GetPixelColorsOfRow (self, int y)
 
ctypes.Array GetPixelColorsOfColumn (self, int x)
 
ctypes.Array GetPixelColorsOfRect (self, int x, int y, int width, int height)
 
bool SetPixelColorsOfRect (self, int x, int y, int width, int height, Iterable[int] colors)
 
List[ctypes.Array] GetPixelColorsOfRects (self, List[Tuple[int, int, int, int]] rects)
 
ctypes.Array GetAllPixelColors (self)
 
'BitmapGetSubBitmap (self, int x, int y, int width, int height)
 

詳解

A simple Bitmap class wraps Windows GDI+ Gdiplus::Bitmap, but may not have high efficiency.

構築子と解体子

◆ __init__()

def uiautomation.uiautomation.Bitmap.__init__ (   self,
int   width = 0,
int   height = 0 
)
Create a black bimap of size(width, height).

◆ __del__()

def uiautomation.uiautomation.Bitmap.__del__ (   self)

メソッド詳解

◆ FromControl()

bool uiautomation.uiautomation.Bitmap.FromControl (   self,
'Control control,
int   x = 0,
int   y = 0,
int   width = 0,
int   height = 0 
)
Capture a control to Bitmap.
control: `Control` or its subclass.
x: int.
y: int.
width: int.
height: int.
x, y: the point in control's internal position(from 0,0)
width, height: image's width and height from x, y, use 0 for entire area,
If width(or height) < 0, image size will be control's width(or height) - width(or height).
Return bool, True if succeed otherwise False.

◆ FromFile()

bool uiautomation.uiautomation.Bitmap.FromFile (   self,
str  filePath 
)
Load image from a file.
filePath: str.
Return bool, True if succeed otherwise False.

◆ FromHandle()

bool uiautomation.uiautomation.Bitmap.FromHandle (   self,
int  hwnd,
int   left = 0,
int   top = 0,
int   right = 0,
int   bottom = 0 
)
Capture a native window to Bitmap by its handle.
hwnd: int, the handle of a native window.
left: int.
top: int.
right: int.
bottom: int.
left, top, right and bottom are control's internal postion(from 0,0).
Return bool, True if succeed otherwise False.

◆ GetAllPixelColors()

ctypes.Array uiautomation.uiautomation.Bitmap.GetAllPixelColors (   self)
Return `ctypes.Array`, an iterable array of int values in argb.

◆ GetPixelColor()

int uiautomation.uiautomation.Bitmap.GetPixelColor (   self,
int  x,
int  y 
)
Get color value of a pixel.
x: int.
y: int.
Return int, argb color.
b = argb & 0x0000FF
g = (argb & 0x00FF00) >> 8
r = (argb & 0xFF0000) >> 16
a = (argb & 0xFF0000) >> 24

◆ GetPixelColorsHorizontally()

ctypes.Array uiautomation.uiautomation.Bitmap.GetPixelColorsHorizontally (   self,
int  x,
int  y,
int  count 
)
x: int.
y: int.
count: int.
Return `ctypes.Array`, an iterable array of int values in argb form point x,y horizontally.

◆ GetPixelColorsOfColumn()

ctypes.Array uiautomation.uiautomation.Bitmap.GetPixelColorsOfColumn (   self,
int  x 
)
x: int, column index.
Return `ctypes.Array`, an iterable array of int values in argb of x column.

◆ GetPixelColorsOfRect()

ctypes.Array uiautomation.uiautomation.Bitmap.GetPixelColorsOfRect (   self,
int  x,
int  y,
int  width,
int  height 
)
x: int.
y: int.
width: int.
height: int.
Return `ctypes.Array`, an iterable array of int values in argb of the input rect.

◆ GetPixelColorsOfRects()

List[ctypes.Array] uiautomation.uiautomation.Bitmap.GetPixelColorsOfRects (   self,
List[Tuple[int, int, int, int]]  rects 
)
rects: List[Tuple[int, int, int, int]], such as [(0,0,10,10), (10,10,20,20), (x,y,width,height)].
Return List[ctypes.Array], a list whose elements are ctypes.Array which is an iterable array of int values in argb.

◆ GetPixelColorsOfRow()

ctypes.Array uiautomation.uiautomation.Bitmap.GetPixelColorsOfRow (   self,
int  y 
)
y: int, row index.
Return `ctypes.Array`, an iterable array of int values in argb of y row.

◆ GetPixelColorsVertically()

ctypes.Array uiautomation.uiautomation.Bitmap.GetPixelColorsVertically (   self,
int  x,
int  y,
int  count 
)
x: int.
y: int.
count: int.
Return `ctypes.Array`, an iterable array of int values in argb form point x,y vertically.

◆ GetSubBitmap()

'Bitmap' uiautomation.uiautomation.Bitmap.GetSubBitmap (   self,
int  x,
int  y,
int  width,
int  height 
)
x: int.
y: int.
width: int.
height: int.
Return `Bitmap`, a sub bitmap of the input rect.

◆ Height()

int uiautomation.uiautomation.Bitmap.Height (   self)
Property Height.
Return int.

◆ Release()

None uiautomation.uiautomation.Bitmap.Release (   self)

◆ SetPixelColor()

bool uiautomation.uiautomation.Bitmap.SetPixelColor (   self,
int  x,
int  y,
int  argb 
)
Set color value of a pixel.
x: int.
y: int.
argb: int, color value.
Return bool, True if succeed otherwise False.

◆ SetPixelColorsHorizontally()

bool uiautomation.uiautomation.Bitmap.SetPixelColorsHorizontally (   self,
int  x,
int  y,
Iterable[int]  colors 
)
Set pixel colors form x,y horizontally.
x: int.
y: int.
colors: Iterable[int], an iterable list of int color values in argb.
Return bool, True if succeed otherwise False.

◆ SetPixelColorsOfRect()

bool uiautomation.uiautomation.Bitmap.SetPixelColorsOfRect (   self,
int  x,
int  y,
int  width,
int  height,
Iterable[int]  colors 
)
x: int.
y: int.
width: int.
height: int.
colors: Iterable[int], an iterable list of int values in argb, it's length must equal to width*height.
Return bool.

◆ SetPixelColorsVertically()

bool uiautomation.uiautomation.Bitmap.SetPixelColorsVertically (   self,
int  x,
int  y,
Iterable[int]  colors 
)
Set pixel colors form x,y vertically.
x: int.
y: int.
colors: Iterable[int], an iterable list of int color values in argb.
Return bool, True if succeed otherwise False.

◆ ToFile()

bool uiautomation.uiautomation.Bitmap.ToFile (   self,
str  savePath 
)
Save to a file.
savePath: str, should end with .bmp, .jpg, .jpeg, .png, .gif, .tif, .tiff.
Return bool, True if succeed otherwise False.

◆ Width()

int uiautomation.uiautomation.Bitmap.Width (   self)
Property Width.
Return int.

このクラス詳解は次のファイルから抽出されました: