Results 1 to 6 of 6

Thread: Pattern drawing like image multiply draw mode

  1. #1
    Junior Member
    Join Date
    Jan 2008
    Posts
    3

    Pattern drawing like image multiply draw mode

    Hi,
    I'm just wondering if there's any way to draw pattern(paint) like drawing image in VG_DRAW_IMAGE_MULTIPLY.
    I could not find any.

    OpenVG can draw image with some alpha value as its spec document says.
    But that image draw mode only applies to vgDrawImage as long as I can find.

    I'd like to draw my Pattern Paint in a VGPath with some alpha value.
    I'm afraid that it's not possible.
    And as far as I concerned, pattern is still a VGImage so if it's not possible, that doesn't make any sense, does it?

  2. #2
    Junior Member
    Join Date
    Jul 2006
    Location
    Rimini, Italy
    Posts
    18

    Re: Pattern drawing like image multiply draw mode

    When you draw a VGImage in VG_DRAW_IMAGE_MULTIPLY mode, OpenVG do (Paint)x(VGImage pixels) operation.
    Because the Pattern is a Paint, now i'm just wondering what kind of result you want to achieve: (Pattern Paint)x(Pattern Paint) ?
    Michele Fabbri - Mazatech Srl

  3. #3
    Junior Member
    Join Date
    Jan 2008
    Posts
    3
    Thanks for your reply.

    I'd like to draw a VGPath(not VGImage) with Pattern Paint of which pattern image being applied some alpha value.
    But simply once we assign pattern image to paint by vgPaintPattern(), we couldn't do anything to that pattern image. Am I right?

    I can say what I'd like to achieve is (Pattern Paint)x(Solid Paint) when I draw VGPath.

  4. #4
    Senior Member
    Join Date
    Feb 2006
    Posts
    115
    Quote Originally Posted by yuneng
    Thanks for your reply.

    I'd like to draw a VGPath(not VGImage) with Pattern Paint of which pattern image being applied some alpha value.
    But simply once we assign pattern image to paint by vgPaintPattern(), we couldn't do anything to that pattern image. Am I right?

    I can say what I'd like to achieve is (Pattern Paint)x(Solid Paint) when I draw VGPath.
    Well, you're right, you cannot apply 2 paints at once to path data (excluding one paint for fill and a different one to stroke when the the path is being filled and stroked of course).

    My suggestion is that you create a temporary image where the Image you want to use as Pattern Paint and the Solid Paint already blended, and use that as the pattern paint instead. You should be able to find a function that will be useful to you in the imagefilter section of the spec (e.g. vgColorMatrix() should do the trick, [maybe even vgLookup()]).

    Alternatatively, if all you are interested is basically modifying the alpha channel, have you considered using the Alphamask (vgMask()) [that is what it's there for]?

    If ALL else fails, then you can always vgGetImageSubData() / vgImageSubData() and modify the image yourself to suit your needs.

  5. #5
    Junior Member
    Join Date
    Jan 2008
    Posts
    3
    really appreciate your reply.

    I am actually doing what you suggested here.
    I have a pattern image to render and whenever something changed, I change that image with vgColorMatrix() and set to pattern image again.
    But it's happening too many times.

    In case of vgMask(), I should create another VGImage with different alpha value. That is almost same to vgColorMatrix() does.
    And I could hardly expect that vg masking is quite fast.

    If OpenVG draws VGImage in a special way like MULTIPLY_MODE, etc, it also could draw pattern image in a similiar way.
    That's why I post a question here.
    But I guess it's not possible yet.
    Thanks again.

  6. #6
    Senior Member
    Join Date
    Feb 2006
    Posts
    115
    Quote Originally Posted by yuneng
    really appreciate your reply.

    I am actually doing what you suggested here.
    I have a pattern image to render and whenever something changed, I change that image with vgColorMatrix() and set to pattern image again.
    But it's happening too many times.

    In case of vgMask(), I should create another VGImage with different alpha value. That is almost same to vgColorMatrix() does.
    And I could hardly expect that vg masking is quite fast.

    If OpenVG draws VGImage in a special way like MULTIPLY_MODE, etc, it also could draw pattern image in a similiar way.
    That's why I post a question here.
    But I guess it's not possible yet.
    Thanks again.
    My guess is that it wont be that slow doing it with an alpha mask - especially if you're changing the value nearly every frame. I'd expect the call to vgColorMatrix() to be slow, as optimizing it, I'd imagine, is on the back burner for nearly every implementor of the VG spec. And there are some weird color conversion rules for that have to be honored for all the image filter functions.

    A call to vgMask() with VG_FILL_MASK should not be much different in terms of speed from a vgClear(). And this is the kind of thing the function is designed to do.

    So the only questions are:
    1) just how expensive is alpha mask during rendering in relation to the setup cost of vgColorMatirx()
    and
    2) how portable/resource intensive do you want it to be - not all surfaces support alpha_mask, and even if they do, you're looking at a byte of pixel of storage space that is required.

    Well, try both ways and see which works best for you. I encourage you to also try vgLookupSingle() instead of vgColorMatrix() - it should be faster as there is no need for any matrix multiplications that way.

    Good luck.

Similar Threads

  1. Help in Image Multiply Mode
    By mkarthik293 in forum OpenVG and VGU
    Replies: 0
    Last Post: 07-16-2008, 11:39 PM
  2. Is the pattern image mutiplied by matrix PAINT to USER?
    By Leezhang in forum OpenVG and VGU
    Replies: 4
    Last Post: 04-25-2007, 08:41 PM

Posting Permissions

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