canvas.draw_image() function does not work
@Trüff perhaps a canvas bug, try this (with, of course, your own file name)
img = ui.Image.named('kitty.JPG') clipboard.set_image(img) #cv.draw_image("kitty.JPG", 0, 0, img_w, img_h) cv.draw_clipboard(0, 0, img_w, img_h)
ccc last edited by ccc
cv.draw_image(ui.Image.named("image.png"), 0, 0, img_w, img_h)
@ccc that does not work, draw_image wants a string as first argument
cv.draw_image(ui.Image.named("kitty.JPG"), 0, 0, img_w, img_h) TypeError: argument 1 must be str, not _ui.Image
@Trüff could you tell me if this solves your problem, thanks
img = ui.Image.named('image.png') clipboard.set_image(img) cv.draw_clipboard(0, 0, img_w, img_h)
Trüff last edited by Trüff
@cvp Hm… Well, it does draw the image onto the canvas. But the image I want to draw is transparent and apparently it just sets a white background for images that are saved into the clipboard. So when I draw the clipboard with the image inside of it, the picture is not transparent anymore.
ccc last edited by
alphalow on the background color like:
Trüff last edited by
@ccc Ok thank you. I‘m going to read the documentary on these modules first.
Keep the alpha low on the background color
If the image he wants to draw is transparent, its background color has already a low alpha.
@Trüff I don't know if you really need a canvas, else, please try this
import ui v = ui.View() v.background_color = 'yellow' iv = ui.ImageView() iv.background_color = 'red' iv.image = ui.Image.named('image.png') wi,hi = iv.image.size iv.frame = (10,10,150,150*hi/wi) v.add_subview(iv) v.present('fullscreen')
Trüff last edited by
@cvp This also doesn‘t work with transparent pictures for me. However, I tried out your previous idea of saving the image into the clipboard and drawing the clipboard but I used the class
PILmodule instead of the one from Pythonista‘s
uimodule and that worked. Thank you!
This also doesn‘t work with transparent pictures for me
Weird, for me it works, the image of my example has a transparent background, here in red
but I used the class Image from the PIL module instead of the one from Pythonista‘s ui module and that worked