「Community:Science/Robotics/Scripts/ImageGrabber」の版間の差分
< Community:Science | Robotics | Scripts
細 (moved Robotics/Scripts/ImageGrabber to Community:Science/Robotics/Scripts/ImageGrabber: moving under Community:Science ("Community" being a new namespace)) |
細 (1版 をインポートしました) |
(相違点なし)
| |
2018年6月29日 (金) 03:41時点における最新版
Image Grabber
The script grabs a very small portion of screen (8px X 8px) around the current position of the mouse, through the OpenGL buffer, and save it.
import Blender
from Blender.BGL import *
import Image
coords = Blender.Window.GetMouseCoords()
imX = 8
imY = 8
depth = 3 # 3 channels RGB
buf = Buffer(GL_BYTE, imX * imY * depth)
glReadPixels(coords[0], coords[1], imX, imY, GL_RGB, GL_BYTE, buf)
image = Image.new('RGB', (imX, imY))
for i in range(imX):
for j in range(imY):
pos = (i * imY + j) * depth
image.putpixel((i, j), ( buf.list[pos], buf.list[pos + 1], buf.list[pos + 2]))
image = image.transpose(2) #rotate 90 degre
image.save('test.png')
print 'Image saved'