2009-06-01 09:55:11 +00:00
|
|
|
# Created By: Virgil Dupras
|
|
|
|
# Created On: 2009-05-10
|
2015-01-03 21:30:57 +00:00
|
|
|
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
2014-10-13 19:08:59 +00:00
|
|
|
#
|
2015-01-03 21:33:16 +00:00
|
|
|
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
2014-10-13 19:08:59 +00:00
|
|
|
# which should be included with this package. The terms are also available at
|
2015-01-03 21:33:16 +00:00
|
|
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2022-05-09 06:40:08 +00:00
|
|
|
from qt.pe._block_qt import getblocks # NOQA
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2010-01-31 10:25:47 +00:00
|
|
|
# Converted to C
|
2009-06-01 09:55:11 +00:00
|
|
|
# def getblock(image):
|
|
|
|
# width = image.width()
|
|
|
|
# height = image.height()
|
|
|
|
# if width:
|
|
|
|
# pixel_count = width * height
|
|
|
|
# red = green = blue = 0
|
|
|
|
# s = image.bits().asstring(image.numBytes())
|
|
|
|
# for i in xrange(pixel_count):
|
|
|
|
# offset = i * 3
|
|
|
|
# red += ord(s[offset])
|
|
|
|
# green += ord(s[offset + 1])
|
|
|
|
# blue += ord(s[offset + 2])
|
|
|
|
# return (red // pixel_count, green // pixel_count, blue // pixel_count)
|
|
|
|
# else:
|
|
|
|
# return (0, 0, 0)
|
2014-10-13 19:08:59 +00:00
|
|
|
#
|
2009-06-01 09:55:11 +00:00
|
|
|
# def getblocks(image, block_count_per_side):
|
|
|
|
# width = image.width()
|
|
|
|
# height = image.height()
|
|
|
|
# if not width:
|
|
|
|
# return []
|
|
|
|
# block_width = max(width // block_count_per_side, 1)
|
|
|
|
# block_height = max(height // block_count_per_side, 1)
|
|
|
|
# result = []
|
|
|
|
# for ih in xrange(block_count_per_side):
|
|
|
|
# top = min(ih * block_height, height - block_height)
|
|
|
|
# for iw in range(block_count_per_side):
|
|
|
|
# left = min(iw * block_width, width - block_width)
|
|
|
|
# crop = image.copy(left, top, block_width, block_height)
|
|
|
|
# result.append(getblock(crop))
|
|
|
|
# return result
|