PDA

View Full Version : Pattern drawing like image multiply draw mode



yuneng
01-09-2008, 11:51 PM
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?

mfabbri
01-10-2008, 07:06 AM
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) ?

yuneng
01-10-2008, 10:28 PM
Thanks for your reply. :D

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.

Ivo Moravec
01-11-2008, 10:53 AM
Thanks for your reply. :D

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.

yuneng
01-24-2008, 10:40 PM
really appreciate your reply. :D

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. 8)

Ivo Moravec
01-25-2008, 12:50 PM
really appreciate your reply. :D

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. 8)

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.