Hi,
Here's the actual code that is doing the work when saving in PNG:
lib/tiledsurface.py (401)
def save_as_png(self, filename, *args, **kwargs):
if not 'alpha' in kwargs:
kwargs['alpha'] = True
if len(self.tiledict) == 1:
kwargs['single_tile_pattern'] = True
pixbufsurface.save_as_png(self, filename, *args, **kwargs)
lib/pixbufsurface.py (126)
def save_as_png(surface, filename, *rect, **kwargs):
alpha = kwargs['alpha']
feedback_cb = kwargs.get('feedback_cb', None)
write_legacy_png = kwargs.get("write_legacy_png", True)
if not rect:
rect = surface.get_bbox()
x, y, w, h = rect
if w == 0 or h == 0:
# workaround to save empty documents
x, y, w, h = 0, 0, 1, 1
# calculate bounding box in full tiles
render_tx = x/N
render_ty = y/N
render_tw = (x+w-1)/N - render_tx + 1
render_th = (y+h-1)/N - render_ty + 1
...
Compare to save png (the whole document, not just the layer):
lib/document.py (642)
def save_png(self, filename, alpha=False, multifile=False, **kwargs):
doc_bbox = self.get_effective_bbox()
if multifile:
self.save_multifile_png(filename, **kwargs)
else:
if alpha:
tmp_layer = layer.Layer()
for l in self.layers:
l.merge_into(tmp_layer)
tmp_layer.save_as_png(filename, *doc_bbox)
else:
pixbufsurface.save_as_png(self, filename, *doc_bbox,
alpha=False, **kwargs)
When to use the get_effective_bbox in pixbufsurface? or maybe it would
be nice to have a real transparent background available in the Layer -
Choose Background?
Thanks
_______________________________________________
Mypaint-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/mypaint-discuss