MCPcopy
hub / github.com/XingangPan/DragGAN / draw_pixels

Function draw_pixels

gui_utils/gl_utils.py:92–111  ·  view source on GitHub ↗
(image, *, pos=0, zoom=1, align=0, rint=True)

Source from the content-addressed store, hash-verified

90#----------------------------------------------------------------------------
91
92def draw_pixels(image, *, pos=0, zoom=1, align=0, rint=True):
93 pos = np.broadcast_to(np.asarray(pos, dtype='float32'), [2])
94 zoom = np.broadcast_to(np.asarray(zoom, dtype='float32'), [2])
95 align = np.broadcast_to(np.asarray(align, dtype='float32'), [2])
96 image = prepare_texture_data(image)
97 height, width, channels = image.shape
98 size = zoom * [width, height]
99 pos = pos - size * align
100 if rint:
101 pos = np.rint(pos)
102 fmt = get_texture_format(image.dtype, channels)
103
104 gl.glPushAttrib(gl.GL_CURRENT_BIT | gl.GL_PIXEL_MODE_BIT)
105 gl.glPushClientAttrib(gl.GL_CLIENT_PIXEL_STORE_BIT)
106 gl.glRasterPos2f(pos[0], pos[1])
107 gl.glPixelZoom(zoom[0], -zoom[1])
108 gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, 1)
109 gl.glDrawPixels(width, height, fmt.format, fmt.type, image)
110 gl.glPopClientAttrib()
111 gl.glPopAttrib()
112
113#----------------------------------------------------------------------------
114

Callers

nothing calls this directly

Calls 2

prepare_texture_dataFunction · 0.85
get_texture_formatFunction · 0.85

Tested by

no test coverage detected