本文整理汇总了Python中PySide.QtGui.QImage.scanLine方法的典型用法代码示例。如果您正苦于以下问题:Python QImage.scanLine方法的具体用法?Python QImage.scanLine怎么用?Python QImage.scanLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QImage
的用法示例。
在下文中一共展示了QImage.scanLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: export_height_map
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import scanLine [as 别名]
def export_height_map(self):
name = QtGui.QFileDialog.getSaveFileName(self,
'Export Heightmap', filter = IMAGE_SAVE_FILTER)[0]
if not name:
return
height_packed = []
for z in xrange(0, 64):
height = (63 - z) * 4
height_packed.append(struct.pack('I', QtGui.qRgba(height, height, height, 255)))
height_image = QImage(512, 512, QImage.Format_ARGB32)
height_lines = []
height_found = []
for y in xrange(0, 512):
height_lines.append(height_image.scanLine(y))
height_found.append([])
for x in xrange(0, 512):
height_found[y].append(False)
progress = progress_dialog(self.edit_widget, 0, 63, 'Exporting Heightmap...')
for z in xrange(0, 64):
if progress.wasCanceled():
break
progress.setValue(z)
packed_value = height_packed[z]
image = self.layers[z]
for y in xrange(0, 512):
image_line = image.scanLine(y)
height_line = height_lines[y]
for x in xrange(0, 512):
if height_found[y][x] is False:
s = x * 4
if image_line[s:s + 4] != TRANSPARENT_PACKED:
height_found[y][x] = True
height_line[s:s + 4] = packed_value
height_image.save(name)
示例2: export_color_map
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import scanLine [as 别名]
def export_color_map(self):
name = QtGui.QFileDialog.getSaveFileName(self,
'Export Colormap', filter = IMAGE_SAVE_FILTER)[0]
if not name:
return
color_image = QImage(512, 512, QImage.Format_ARGB32)
color_lines = []
height_found = []
for y in xrange(0, 512):
color_lines.append(color_image.scanLine(y))
height_found.append([])
for x in xrange(0, 512):
height_found[y].append(False)
progress = progress_dialog(self.edit_widget, 0, 63, 'Exporting Colormap...')
for z in xrange(0, 64):
if progress.wasCanceled():
break
progress.setValue(z)
image = self.layers[z]
for y in xrange(0, 512):
image_line = image.scanLine(y)
color_line = color_lines[y]
for x in xrange(0, 512):
if height_found[y][x] is False:
s = x * 4
image_pixel = image_line[s:s + 4]
if image_pixel != TRANSPARENT_PACKED:
height_found[y][x] = True
color_line[s:s + 4] = image_pixel
color_image.save(name)
示例3: generate_heightmap
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import scanLine [as 别名]
def generate_heightmap(self, delete = False):
h_name = QtGui.QFileDialog.getOpenFileName(self,
'Select heightmap file', filter = IMAGE_OPEN_FILTER)[0]
if not h_name:
return
h_image = QImage(h_name)
if not delete:
c_name = QtGui.QFileDialog.getOpenFileName(self,
'Select colormap file', filter = IMAGE_OPEN_FILTER)[0]
if not c_name:
return
c_image = QImage(c_name)
height_values = []
color_lines = []
for y in xrange(0, 512):
height_values.append([])
height_line = h_image.scanLine(y)
if not delete:
color_lines.append(c_image.scanLine(y))
for x in xrange(0,512):
height_values[y].append(self.get_height(
struct.unpack('I', height_line[x * 4:x * 4 + 4])[0]))
progress = progress_dialog(self.edit_widget, 0, 63,
'Generating from heightmap...')
for z, image in enumerate(reversed(self.layers)):
if progress.wasCanceled():
break
progress.setValue(z)
if z == 0 and delete:
continue
for y in xrange(0, 512):
image_line = image.scanLine(y)
if not delete:
color_line = color_lines[y]
for x in xrange(0, 512):
if z <= height_values[y][x]:
s = x * 4
if not delete:
image_line[s:s + 4] = color_line[s:s + 4]
else:
image_line[s:s + 4] = TRANSPARENT_PACKED
image.dirty = True
self.set_dirty()
示例4: image_from_hbitmap
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import scanLine [as 别名]
def image_from_hbitmap(hdc, bitmap, width, height):
bitmap_info = BITMAPINFO()
memset(byref(bitmap_info), 0, sizeof(bitmap_info))
bitmap_info.bmiHeader.biSize = sizeof(bitmap_info.bmiHeader)
bitmap_info.bmiHeader.biWidth = width
bitmap_info.bmiHeader.biHeight = -height
bitmap_info.bmiHeader.biPlanes = 1
bitmap_info.bmiHeader.biBitCount = 32
bitmap_info.bmiHeader.biCompression = BI_RGB
bitmap_info.bmiHeader.biSizeImage = width * height * 4
image = QImage(width, height, QImage.Format_ARGB32_Premultiplied)
if image.isNull(): return image
data = (c_ubyte * bitmap_info.bmiHeader.biSizeImage)()
if not GetDIBits(hdc, bitmap, 0, height, data, byref(bitmap_info),
DIB_RGB_COLORS):
raise WindowsError('call to GetDIBits failed')
bytes_per_line = image.bytesPerLine()
for y in xrange(0, height):
offset = y * bytes_per_line
line = image.scanLine(y)
for x in xrange(0, bytes_per_line):
line[x] = chr(data[offset + x])
return image