×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    6

    The mask of the rectangles

    Dear Nokia.Forum community,

    I have yet another question regarding the mask function in python.
    What I want to do:
    I want to have one main image that will be my background loaded from image(img), and I want to have another image on top of the background image (imgtop). Then I want to make e.g. two rectangles on the imgtop image and I wish to put the imgtop over the img and see the background image and the rectangles from imgtop with the mask. I saw a function that iterates through .png file and makes another mask image on the wiki. Is there any way to make a mask from user's made rectangles, ovals, ellipses, lines etc.? Or I have to make a mask image everytime I declare new rectangle, oval etc.?

    Is there a way to iterate through user's made graphics within an image?

    Thanks in advance,
    Peter

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    6

    Re: The mask of the rectangles

    Okay so I'll give you an example of my code:
    Code:
    img=graphics.Image.open(path+"img\\Bar.jpg")
    
    img2 = graphics.Image.new((100,100))
    img2.rectangle((0,0,30,60), fill=0xFF0000)
    img2.rectangle((40,10,50,80), fill=0xFF0000)
    img.blit(img2, mask = img2GENERATEDMASK)
    As you can see, we have img and the 2nd image with rectangles and I wish to have mask for the 2nd image generated automatically. Is it possible?

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    6

    Re: The mask of the rectangles

    Anyone? Please...

  4. #4
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: The mask of the rectangles

    Quote Originally Posted by Galfar0th View Post
    Anyone? Please...
    Hi ! Take a look on this article:
    How to display transparent PNG on canvas with masks


    It may give you some ideas.

    Marcelo Barros

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    6

    Re: The mask of the rectangles

    Thank you for the reply marcolo, but as I stated before, I've already seen that. The problem is our hand-made image is not .png file and It has no alpha channel while we draw the rectangles on that.

    So we have to make this somehow different.

  6. #6
    Registered User
    Join Date
    Nov 2008
    Posts
    4

    Re: The mask of the rectangles

    I'm not sure if I understood what you are asking, in particular with what you mean with "automatically", I guess you already know what I'm about to explain below, but well, I guess that the answer is no. As far as I know (at least on PyS60 1.4.4) you would need to create the masks yourself, one for each figure (or set of figures) you want to blit. This is, following your example:

    #this is your code
    img=graphics.Image.open(path+"img\\Bar.jpg")
    img2 = graphics.Image.new((100,100))
    img2.rectangle((0,0,30,60), fill=0xFF0000)
    img2.rectangle((40,10,50,80), fill=0xFF0000)

    #here you would need to create the mask yourself
    #mask needs to be an 8 (or 1) bit image

    img2Mask = graphics.Image.new((100,100), 'L')

    #paint it black cause black is invisible

    img2Mask.clear(0x000000)

    #replicate your original drawing but all in white (visible)
    img2Mask.rectangle((0,0,30,60), fill=0xFFFFFF)
    img2Mask.rectangle((40,10,50,80), fill=0xFFFFFF)

    #finally the blit
    img.blit(img2, mask = img2Mask)

Similar Threads

  1. AknIconUtils::CreateIconL - mask or no mask?
    By heuven in forum Symbian User Interface
    Replies: 1
    Last Post: 2008-12-06, 11:38
  2. how to create a mask of image dynamically
    By raysky in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2008-11-03, 05:43
  3. resize picture with mask
    By CmoaToto in forum Symbian
    Replies: 1
    Last Post: 2008-10-22, 01:41
  4. svg mask
    By nokia_e70 in forum Symbian
    Replies: 0
    Last Post: 2008-03-29, 12:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×