Patch to improve blending accuracy of RGBA/RGB/Gray pixel formats

View: New views
11 Messages — Rating Filter:   Alert me  

Patch to improve blending accuracy of RGBA/RGB/Gray pixel formats

by John Horigan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

For my digital art program, Context Free, I have been using a modified form of the RGBA, RGB, and gray pixel formats. I do this because stock AGG is slightly inaccurate in computing and blending colors.  My changes to AGG are based on Alvy Ray Smith's paper on fast, accurate color blending (ftp://ftp.alvyray.com/Acrobat/4_Comp.pdf).

The changes that I have made are:
* Utility methods have been added to classes rgb8, rgb16, gray8, and gray16 for doing fast, accurate fixed point multiplies and linear interpolations.
* The add, gradient, and premultiply methods of classes rgb8, rgb16, gray8, and gray16 use the new utility methods.
* multiplier_rgba<>::premultiply() method in agg_pixfmt_rgba.h uses the new utility methods.
* All of the blender classes in agg_pixfmt_gray/rbg/rgba.h use the new utility methods.
* The interface between these blender classes and the pixfmt classes has been changed slightly. Currently the pixfmt class multiplies the color alpha with pixel coverage factor before calling the blender (even though both alpha and cover are passed to the blender). With this patch, this calculation is moved to the blender class blend_pix() methods.
* I added a utility method to class rect_base in agg_basics.h: overlaps()

I have been using most of these changes for over a year in Context Free and I am confident in their correctness. I don't use the non-premultiplied color blenders but I was able to tweak Context Free to use them and they appeared to function correctly.

The composition operation classes comp_op_rgba_x in agg_pixfmt_rgba.h and the pixfmt_custom_blend_rgba class that uses them have not been updated to use the new utility methods. The composition operators could stand to be implemented more accurately, but I don't have any test bench for validating changes.


-- john


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: Patch to improve blending accuracy of RGBA/RGB/Gray pixel formats

by Petr Kobalíček :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi John,

the file you linking is not accessible, please can you post working
link, I'd like to read it.

How do you want to support blending in non-premultiplied colorspace?
I'm doing this in Fog library and only way to get this working is
premultiply, do blending, demultiply - quite slow.

Thanks
- Petr

2009/8/17 John Horigan <john@...>:

> For my digital art program, Context Free, I have been using a modified form
> of the RGBA, RGB, and gray pixel formats. I do this because stock AGG is
> slightly inaccurate in computing and blending colors.  My changes to AGG are
> based on Alvy Ray Smith's paper on fast, accurate color
> blending (ftp://ftp.alvyray.com/Acrobat/4_Comp.pdf).
> The changes that I have made are:
> * Utility methods have been added to classes rgb8, rgb16, gray8, and gray16
> for doing fast, accurate fixed point multiplies and linear interpolations.
> * The add, gradient, and premultiply methods of classes rgb8, rgb16, gray8,
> and gray16 use the new utility methods.
> * multiplier_rgba<>::premultiply() method in agg_pixfmt_rgba.h uses the new
> utility methods.
> * All of the blender classes in agg_pixfmt_gray/rbg/rgba.h use the new
> utility methods.
> * The interface between these blender classes and the pixfmt classes has
> been changed slightly. Currently the pixfmt class multiplies the color alpha
> with pixel coverage factor before calling the blender (even though both
> alpha and cover are passed to the blender). With this patch, this
> calculation is moved to the blender class blend_pix() methods.
> * I added a utility method to class rect_base in agg_basics.h: overlaps()
> I have been using most of these changes for over a year in Context Free and
> I am confident in their correctness. I don't use the non-premultiplied color
> blenders but I was able to tweak Context Free to use them and they appeared
> to function correctly.
> The composition operation classes comp_op_rgba_x in agg_pixfmt_rgba.h and
> the pixfmt_custom_blend_rgba class that uses them have not been updated to
> use the new utility methods. The composition operators could stand to be
> implemented more accurately, but I don't have any test bench for validating
> changes.
> The patch can be found at
> http://www.ozonehouse.com/john/agg24_alvyraysmith.patch
> -- john
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: Patch to improve blending accuracy of RGBA/RGB/Gray pixel formats

by John Horigan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK. I avoided posting the patch because it is larger than 50k. But  
here is a gzipped copy of it.






-- john


On Aug 17, 2009, at 4:44 AM, Petr Kobalíček wrote:

> Hi John,
>
> the file you linking is not accessible, please can you post working
> link, I'd like to read it.
>
> How do you want to support blending in non-premultiplied colorspace?
> I'm doing this in Fog library and only way to get this working is
> premultiply, do blending, demultiply - quite slow.
>
> Thanks
> - Petr
>
> 2009/8/17 John Horigan <john@...>:
>> For my digital art program, Context Free, I have been using a  
>> modified form
>> of the RGBA, RGB, and gray pixel formats. I do this because stock  
>> AGG is
>> slightly inaccurate in computing and blending colors.  My changes  
>> to AGG are
>> based on Alvy Ray Smith's paper on fast, accurate color
>> blending (ftp://ftp.alvyray.com/Acrobat/4_Comp.pdf).
>> The changes that I have made are:
>> * Utility methods have been added to classes rgb8, rgb16, gray8,  
>> and gray16
>> for doing fast, accurate fixed point multiplies and linear  
>> interpolations.
>> * The add, gradient, and premultiply methods of classes rgb8,  
>> rgb16, gray8,
>> and gray16 use the new utility methods.
>> * multiplier_rgba<>::premultiply() method in agg_pixfmt_rgba.h uses  
>> the new
>> utility methods.
>> * All of the blender classes in agg_pixfmt_gray/rbg/rgba.h use the  
>> new
>> utility methods.
>> * The interface between these blender classes and the pixfmt  
>> classes has
>> been changed slightly. Currently the pixfmt class multiplies the  
>> color alpha
>> with pixel coverage factor before calling the blender (even though  
>> both
>> alpha and cover are passed to the blender). With this patch, this
>> calculation is moved to the blender class blend_pix() methods.
>> * I added a utility method to class rect_base in agg_basics.h:  
>> overlaps()
>> I have been using most of these changes for over a year in Context  
>> Free and
>> I am confident in their correctness. I don't use the non-
>> premultiplied color
>> blenders but I was able to tweak Context Free to use them and they  
>> appeared
>> to function correctly.
>> The composition operation classes comp_op_rgba_x in  
>> agg_pixfmt_rgba.h and
>> the pixfmt_custom_blend_rgba class that uses them have not been  
>> updated to
>> use the new utility methods. The composition operators could stand  
>> to be
>> implemented more accurately, but I don't have any test bench for  
>> validating
>> changes.
>> The patch can be found at
>> http://www.ozonehouse.com/john/agg24_alvyraysmith.patch
>> -- john
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports  
>> 2008 30-Day
>> trial. Simplify your report design, integration and deployment -  
>> and focus
>> on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Vector-agg-general mailing list
>> Vector-agg-general@...
>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>
>>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008  
> 30-Day
> trial. Simplify your report design, integration and deployment - and  
> focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

agg24_alvyraysmith.patch.gz (6K) Download Attachment

Re: Patch to improve blending accuracy of RGBA/RGB/Gray pixel formats

by Petr Kobalíček :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi John,

thanks, but I talked about the pdf document :-) But I will study you path too :)

2009/8/17 John Horigan <john@...>:

> OK. I avoided posting the patch because it is larger than 50k. But here is a
> gzipped copy of it.
>
>
>
>
>
> -- john
>
>
> On Aug 17, 2009, at 4:44 AM, Petr Kobalíček wrote:
>
>> Hi John,
>>
>> the file you linking is not accessible, please can you post working
>> link, I'd like to read it.
>>
>> How do you want to support blending in non-premultiplied colorspace?
>> I'm doing this in Fog library and only way to get this working is
>> premultiply, do blending, demultiply - quite slow.
>>
>> Thanks
>> - Petr
>>
>> 2009/8/17 John Horigan <john@...>:
>>>
>>> For my digital art program, Context Free, I have been using a modified
>>> form
>>> of the RGBA, RGB, and gray pixel formats. I do this because stock AGG is
>>> slightly inaccurate in computing and blending colors.  My changes to AGG
>>> are
>>> based on Alvy Ray Smith's paper on fast, accurate color
>>> blending (ftp://ftp.alvyray.com/Acrobat/4_Comp.pdf).
>>> The changes that I have made are:
>>> * Utility methods have been added to classes rgb8, rgb16, gray8, and
>>> gray16
>>> for doing fast, accurate fixed point multiplies and linear
>>> interpolations.
>>> * The add, gradient, and premultiply methods of classes rgb8, rgb16,
>>> gray8,
>>> and gray16 use the new utility methods.
>>> * multiplier_rgba<>::premultiply() method in agg_pixfmt_rgba.h uses the
>>> new
>>> utility methods.
>>> * All of the blender classes in agg_pixfmt_gray/rbg/rgba.h use the new
>>> utility methods.
>>> * The interface between these blender classes and the pixfmt classes has
>>> been changed slightly. Currently the pixfmt class multiplies the color
>>> alpha
>>> with pixel coverage factor before calling the blender (even though both
>>> alpha and cover are passed to the blender). With this patch, this
>>> calculation is moved to the blender class blend_pix() methods.
>>> * I added a utility method to class rect_base in agg_basics.h: overlaps()
>>> I have been using most of these changes for over a year in Context Free
>>> and
>>> I am confident in their correctness. I don't use the non-premultiplied
>>> color
>>> blenders but I was able to tweak Context Free to use them and they
>>> appeared
>>> to function correctly.
>>> The composition operation classes comp_op_rgba_x in agg_pixfmt_rgba.h and
>>> the pixfmt_custom_blend_rgba class that uses them have not been updated
>>> to
>>> use the new utility methods. The composition operators could stand to be
>>> implemented more accurately, but I don't have any test bench for
>>> validating
>>> changes.
>>> The patch can be found at
>>> http://www.ozonehouse.com/john/agg24_alvyraysmith.patch
>>> -- john
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> 30-Day
>>> trial. Simplify your report design, integration and deployment - and
>>> focus
>>> on
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> _______________________________________________
>>> Vector-agg-general mailing list
>>> Vector-agg-general@...
>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> 30-Day
>> trial. Simplify your report design, integration and deployment - and focus
>> on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Vector-agg-general mailing list
>> Vector-agg-general@...
>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: Patch to improve blending accuracy of RGBA/RGB/Gray pixel formats

by John Horigan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK. I can host that too.

http://www.ozonehouse.com/john/4_Comp.pdf

-- john


On Aug 17, 2009, at 8:26 AM, Petr Kobalíček wrote:

> Hi John,
>
> thanks, but I talked about the pdf document :-) But I will study you  
> path too :)
>
> 2009/8/17 John Horigan <john@...>:
>> OK. I avoided posting the patch because it is larger than 50k. But  
>> here is a
>> gzipped copy of it.
>>
>>
>>
>>
>>
>> -- john
>>
>>
>> On Aug 17, 2009, at 4:44 AM, Petr Kobalíček wrote:
>>
>>> Hi John,
>>>
>>> the file you linking is not accessible, please can you post working
>>> link, I'd like to read it.
>>>
>>> How do you want to support blending in non-premultiplied colorspace?
>>> I'm doing this in Fog library and only way to get this working is
>>> premultiply, do blending, demultiply - quite slow.
>>>
>>> Thanks
>>> - Petr
>>>
>>> 2009/8/17 John Horigan <john@...>:
>>>>
>>>> For my digital art program, Context Free, I have been using a  
>>>> modified
>>>> form
>>>> of the RGBA, RGB, and gray pixel formats. I do this because stock  
>>>> AGG is
>>>> slightly inaccurate in computing and blending colors.  My changes  
>>>> to AGG
>>>> are
>>>> based on Alvy Ray Smith's paper on fast, accurate color
>>>> blending (ftp://ftp.alvyray.com/Acrobat/4_Comp.pdf).
>>>> The changes that I have made are:
>>>> * Utility methods have been added to classes rgb8, rgb16, gray8,  
>>>> and
>>>> gray16
>>>> for doing fast, accurate fixed point multiplies and linear
>>>> interpolations.
>>>> * The add, gradient, and premultiply methods of classes rgb8,  
>>>> rgb16,
>>>> gray8,
>>>> and gray16 use the new utility methods.
>>>> * multiplier_rgba<>::premultiply() method in agg_pixfmt_rgba.h  
>>>> uses the
>>>> new
>>>> utility methods.
>>>> * All of the blender classes in agg_pixfmt_gray/rbg/rgba.h use  
>>>> the new
>>>> utility methods.
>>>> * The interface between these blender classes and the pixfmt  
>>>> classes has
>>>> been changed slightly. Currently the pixfmt class multiplies the  
>>>> color
>>>> alpha
>>>> with pixel coverage factor before calling the blender (even  
>>>> though both
>>>> alpha and cover are passed to the blender). With this patch, this
>>>> calculation is moved to the blender class blend_pix() methods.
>>>> * I added a utility method to class rect_base in agg_basics.h:  
>>>> overlaps()
>>>> I have been using most of these changes for over a year in  
>>>> Context Free
>>>> and
>>>> I am confident in their correctness. I don't use the non-
>>>> premultiplied
>>>> color
>>>> blenders but I was able to tweak Context Free to use them and they
>>>> appeared
>>>> to function correctly.
>>>> The composition operation classes comp_op_rgba_x in  
>>>> agg_pixfmt_rgba.h and
>>>> the pixfmt_custom_blend_rgba class that uses them have not been  
>>>> updated
>>>> to
>>>> use the new utility methods. The composition operators could  
>>>> stand to be
>>>> implemented more accurately, but I don't have any test bench for
>>>> validating
>>>> changes.
>>>> The patch can be found at
>>>> http://www.ozonehouse.com/john/agg24_alvyraysmith.patch
>>>> -- john
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Let Crystal Reports handle the reporting - Free Crystal Reports  
>>>> 2008
>>>> 30-Day
>>>> trial. Simplify your report design, integration and deployment -  
>>>> and
>>>> focus
>>>> on
>>>> what you do best, core application coding. Discover what's new with
>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>> _______________________________________________
>>>> Vector-agg-general mailing list
>>>> Vector-agg-general@...
>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>>
>>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> 30-Day
>>> trial. Simplify your report design, integration and deployment -  
>>> and focus
>>> on
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> _______________________________________________
>>> Vector-agg-general mailing list
>>> Vector-agg-general@...
>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports  
>> 2008 30-Day
>> trial. Simplify your report design, integration and deployment -  
>> and focus
>> on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Vector-agg-general mailing list
>> Vector-agg-general@...
>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>
>>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008  
> 30-Day
> trial. Simplify your report design, integration and deployment - and  
> focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: Patch to improve blending accuracy of RGBA/RGB/Gray pixel formats

by Petr Kobalíček :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I know this paper, it's good explanation.

I read your code and there is one possibility to improve speed by
using double-blend trick. It's used by pixman library and I'm using it
in Fog. This trick is used to multiply two unsigned 8 bit integers
packed in one 32 bit integer.

Best regards
- Petr

2009/8/17 John Horigan <john@...>:

> OK. I can host that too.
>
> http://www.ozonehouse.com/john/4_Comp.pdf
>
> -- john
>
>
> On Aug 17, 2009, at 8:26 AM, Petr Kobalíček wrote:
>
>> Hi John,
>>
>> thanks, but I talked about the pdf document :-) But I will study you
>> path too :)
>>
>> 2009/8/17 John Horigan <john@...>:
>>> OK. I avoided posting the patch because it is larger than 50k. But
>>> here is a
>>> gzipped copy of it.
>>>
>>>
>>>
>>>
>>>
>>> -- john
>>>
>>>
>>> On Aug 17, 2009, at 4:44 AM, Petr Kobalíček wrote:
>>>
>>>> Hi John,
>>>>
>>>> the file you linking is not accessible, please can you post working
>>>> link, I'd like to read it.
>>>>
>>>> How do you want to support blending in non-premultiplied colorspace?
>>>> I'm doing this in Fog library and only way to get this working is
>>>> premultiply, do blending, demultiply - quite slow.
>>>>
>>>> Thanks
>>>> - Petr
>>>>
>>>> 2009/8/17 John Horigan <john@...>:
>>>>>
>>>>> For my digital art program, Context Free, I have been using a
>>>>> modified
>>>>> form
>>>>> of the RGBA, RGB, and gray pixel formats. I do this because stock
>>>>> AGG is
>>>>> slightly inaccurate in computing and blending colors.  My changes
>>>>> to AGG
>>>>> are
>>>>> based on Alvy Ray Smith's paper on fast, accurate color
>>>>> blending (ftp://ftp.alvyray.com/Acrobat/4_Comp.pdf).
>>>>> The changes that I have made are:
>>>>> * Utility methods have been added to classes rgb8, rgb16, gray8,
>>>>> and
>>>>> gray16
>>>>> for doing fast, accurate fixed point multiplies and linear
>>>>> interpolations.
>>>>> * The add, gradient, and premultiply methods of classes rgb8,
>>>>> rgb16,
>>>>> gray8,
>>>>> and gray16 use the new utility methods.
>>>>> * multiplier_rgba<>::premultiply() method in agg_pixfmt_rgba.h
>>>>> uses the
>>>>> new
>>>>> utility methods.
>>>>> * All of the blender classes in agg_pixfmt_gray/rbg/rgba.h use
>>>>> the new
>>>>> utility methods.
>>>>> * The interface between these blender classes and the pixfmt
>>>>> classes has
>>>>> been changed slightly. Currently the pixfmt class multiplies the
>>>>> color
>>>>> alpha
>>>>> with pixel coverage factor before calling the blender (even
>>>>> though both
>>>>> alpha and cover are passed to the blender). With this patch, this
>>>>> calculation is moved to the blender class blend_pix() methods.
>>>>> * I added a utility method to class rect_base in agg_basics.h:
>>>>> overlaps()
>>>>> I have been using most of these changes for over a year in
>>>>> Context Free
>>>>> and
>>>>> I am confident in their correctness. I don't use the non-
>>>>> premultiplied
>>>>> color
>>>>> blenders but I was able to tweak Context Free to use them and they
>>>>> appeared
>>>>> to function correctly.
>>>>> The composition operation classes comp_op_rgba_x in
>>>>> agg_pixfmt_rgba.h and
>>>>> the pixfmt_custom_blend_rgba class that uses them have not been
>>>>> updated
>>>>> to
>>>>> use the new utility methods. The composition operators could
>>>>> stand to be
>>>>> implemented more accurately, but I don't have any test bench for
>>>>> validating
>>>>> changes.
>>>>> The patch can be found at
>>>>> http://www.ozonehouse.com/john/agg24_alvyraysmith.patch
>>>>> -- john
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Let Crystal Reports handle the reporting - Free Crystal Reports
>>>>> 2008
>>>>> 30-Day
>>>>> trial. Simplify your report design, integration and deployment -
>>>>> and
>>>>> focus
>>>>> on
>>>>> what you do best, core application coding. Discover what's new with
>>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>>> _______________________________________________
>>>>> Vector-agg-general mailing list
>>>>> Vector-agg-general@...
>>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>>>
>>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>>> 30-Day
>>>> trial. Simplify your report design, integration and deployment -
>>>> and focus
>>>> on
>>>> what you do best, core application coding. Discover what's new with
>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>> _______________________________________________
>>>> Vector-agg-general mailing list
>>>> Vector-agg-general@...
>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports
>>> 2008 30-Day
>>> trial. Simplify your report design, integration and deployment -
>>> and focus
>>> on
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> _______________________________________________
>>> Vector-agg-general mailing list
>>> Vector-agg-general@...
>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>
>>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> 30-Day
>> trial. Simplify your report design, integration and deployment - and
>> focus on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Vector-agg-general mailing list
>> Vector-agg-general@...
>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: Patch to improve blending accuracy of RGBA/RGB/Gray pixel formats

by John Horigan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What about rgba16 pixels? Wouldn't we have to generalize the double-
blend trick to use 32-bit math on 8-bit color channels and 64-bit math  
on 16-bit color channels?

-- john

On Aug 17, 2009, at 8:53 AM, Petr Kobalíček wrote:

> I know this paper, it's good explanation.
>
> I read your code and there is one possibility to improve speed by
> using double-blend trick. It's used by pixman library and I'm using it
> in Fog. This trick is used to multiply two unsigned 8 bit integers
> packed in one 32 bit integer.
>
> Best regards
> - Petr
>
> 2009/8/17 John Horigan <john@...>:
>> OK. I can host that too.
>>
>> http://www.ozonehouse.com/john/4_Comp.pdf
>>
>> -- john
>>
>>
>> On Aug 17, 2009, at 8:26 AM, Petr Kobalíček wrote:
>>
>>> Hi John,
>>>
>>> thanks, but I talked about the pdf document :-) But I will study you
>>> path too :)
>>>
>>> 2009/8/17 John Horigan <john@...>:
>>>> OK. I avoided posting the patch because it is larger than 50k. But
>>>> here is a
>>>> gzipped copy of it.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -- john
>>>>
>>>>
>>>> On Aug 17, 2009, at 4:44 AM, Petr Kobalíček wrote:
>>>>
>>>>> Hi John,
>>>>>
>>>>> the file you linking is not accessible, please can you post  
>>>>> working
>>>>> link, I'd like to read it.
>>>>>
>>>>> How do you want to support blending in non-premultiplied  
>>>>> colorspace?
>>>>> I'm doing this in Fog library and only way to get this working is
>>>>> premultiply, do blending, demultiply - quite slow.
>>>>>
>>>>> Thanks
>>>>> - Petr
>>>>>
>>>>> 2009/8/17 John Horigan <john@...>:
>>>>>>
>>>>>> For my digital art program, Context Free, I have been using a
>>>>>> modified
>>>>>> form
>>>>>> of the RGBA, RGB, and gray pixel formats. I do this because stock
>>>>>> AGG is
>>>>>> slightly inaccurate in computing and blending colors.  My changes
>>>>>> to AGG
>>>>>> are
>>>>>> based on Alvy Ray Smith's paper on fast, accurate color
>>>>>> blending (ftp://ftp.alvyray.com/Acrobat/4_Comp.pdf).
>>>>>> The changes that I have made are:
>>>>>> * Utility methods have been added to classes rgb8, rgb16, gray8,
>>>>>> and
>>>>>> gray16
>>>>>> for doing fast, accurate fixed point multiplies and linear
>>>>>> interpolations.
>>>>>> * The add, gradient, and premultiply methods of classes rgb8,
>>>>>> rgb16,
>>>>>> gray8,
>>>>>> and gray16 use the new utility methods.
>>>>>> * multiplier_rgba<>::premultiply() method in agg_pixfmt_rgba.h
>>>>>> uses the
>>>>>> new
>>>>>> utility methods.
>>>>>> * All of the blender classes in agg_pixfmt_gray/rbg/rgba.h use
>>>>>> the new
>>>>>> utility methods.
>>>>>> * The interface between these blender classes and the pixfmt
>>>>>> classes has
>>>>>> been changed slightly. Currently the pixfmt class multiplies the
>>>>>> color
>>>>>> alpha
>>>>>> with pixel coverage factor before calling the blender (even
>>>>>> though both
>>>>>> alpha and cover are passed to the blender). With this patch, this
>>>>>> calculation is moved to the blender class blend_pix() methods.
>>>>>> * I added a utility method to class rect_base in agg_basics.h:
>>>>>> overlaps()
>>>>>> I have been using most of these changes for over a year in
>>>>>> Context Free
>>>>>> and
>>>>>> I am confident in their correctness. I don't use the non-
>>>>>> premultiplied
>>>>>> color
>>>>>> blenders but I was able to tweak Context Free to use them and  
>>>>>> they
>>>>>> appeared
>>>>>> to function correctly.
>>>>>> The composition operation classes comp_op_rgba_x in
>>>>>> agg_pixfmt_rgba.h and
>>>>>> the pixfmt_custom_blend_rgba class that uses them have not been
>>>>>> updated
>>>>>> to
>>>>>> use the new utility methods. The composition operators could
>>>>>> stand to be
>>>>>> implemented more accurately, but I don't have any test bench for
>>>>>> validating
>>>>>> changes.
>>>>>> The patch can be found at
>>>>>> http://www.ozonehouse.com/john/agg24_alvyraysmith.patch
>>>>>> -- john
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Let Crystal Reports handle the reporting - Free Crystal Reports
>>>>>> 2008
>>>>>> 30-Day
>>>>>> trial. Simplify your report design, integration and deployment -
>>>>>> and
>>>>>> focus
>>>>>> on
>>>>>> what you do best, core application coding. Discover what's new  
>>>>>> with
>>>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>>>> _______________________________________________
>>>>>> Vector-agg-general mailing list
>>>>>> Vector-agg-general@...
>>>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Let Crystal Reports handle the reporting - Free Crystal Reports  
>>>>> 2008
>>>>> 30-Day
>>>>> trial. Simplify your report design, integration and deployment -
>>>>> and focus
>>>>> on
>>>>> what you do best, core application coding. Discover what's new  
>>>>> with
>>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>>> _______________________________________________
>>>>> Vector-agg-general mailing list
>>>>> Vector-agg-general@...
>>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Let Crystal Reports handle the reporting - Free Crystal Reports
>>>> 2008 30-Day
>>>> trial. Simplify your report design, integration and deployment -
>>>> and focus
>>>> on
>>>> what you do best, core application coding. Discover what's new with
>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>> _______________________________________________
>>>> Vector-agg-general mailing list
>>>> Vector-agg-general@...
>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>>
>>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> 30-Day
>>> trial. Simplify your report design, integration and deployment - and
>>> focus on
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> _______________________________________________
>>> Vector-agg-general mailing list
>>> Vector-agg-general@...
>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports  
>> 2008 30-Day
>> trial. Simplify your report design, integration and deployment -  
>> and focus on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Vector-agg-general mailing list
>> Vector-agg-general@...
>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008  
> 30-Day
> trial. Simplify your report design, integration and deployment - and  
> focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: Patch to improve blending accuracy of RGBA/RGB/Gray pixel formats

by Petr Kobalíček :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

on 64 bit cpu there will be benefit, but using 64 bit types on 32 bit
cpu means usually slow-down. But you can use 64-bit integer to blend 4
8-bit integers.

for example I'm using this inline function in Fog:

// x_c = (x_c * a) / 255
static FOG_INLINE uint32_t bytemul(uint32_t x, uint32_t a)
{
#if FOG_ARCH_BITS == 64
  uint64_t x0 = ((uint64_t)x | ((uint64_t)x << 24)) &
FOG_UINT64_C(0x00FF00FF00FF00FF);
  x0 *= a;
  x0 = (x0 + ((x0 >> 8) & FOG_UINT64_C(0x00FF00FF00FF00FF)) +
FOG_UINT64_C(0x0080008000800080)) >> 8;
  x0 &= FOG_UINT64_C(0x00FF00FF00FF00FF);
  return (uint32_t)(x0 | (x0 >> 24));
#else
  uint32_t t0 = ((x & 0x00FF00FF)     ) * a;
  uint32_t t1 = ((x & 0xFF00FF00) >> 8) * a;

  x  = ((t0 + ((t0 >> 8) & 0x00FF00FF) + 0x00800080) >> 8) & 0x00FF00FF;
  x |= ((t1 + ((t1 >> 8) & 0x00FF00FF) + 0x00800080)     ) & 0xFF00FF00;

  return x;
#endif
}

it multiplies each bit in 'x' by 'a' and then divides each bit by 255
(using equal method described in paper you linked).

I think that there is problem that pixel formats are hard to
generalize (generalization usually means to degrade performance)

2009/8/17 John Horigan <john@...>:

> What about rgba16 pixels? Wouldn't we have to generalize the double-
> blend trick to use 32-bit math on 8-bit color channels and 64-bit math
> on 16-bit color channels?
>
> -- john
>
> On Aug 17, 2009, at 8:53 AM, Petr Kobalíček wrote:
>
>> I know this paper, it's good explanation.
>>
>> I read your code and there is one possibility to improve speed by
>> using double-blend trick. It's used by pixman library and I'm using it
>> in Fog. This trick is used to multiply two unsigned 8 bit integers
>> packed in one 32 bit integer.
>>
>> Best regards
>> - Petr
>>
>> 2009/8/17 John Horigan <john@...>:
>>> OK. I can host that too.
>>>
>>> http://www.ozonehouse.com/john/4_Comp.pdf
>>>
>>> -- john
>>>
>>>
>>> On Aug 17, 2009, at 8:26 AM, Petr Kobalíček wrote:
>>>
>>>> Hi John,
>>>>
>>>> thanks, but I talked about the pdf document :-) But I will study you
>>>> path too :)
>>>>
>>>> 2009/8/17 John Horigan <john@...>:
>>>>> OK. I avoided posting the patch because it is larger than 50k. But
>>>>> here is a
>>>>> gzipped copy of it.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- john
>>>>>
>>>>>
>>>>> On Aug 17, 2009, at 4:44 AM, Petr Kobalíček wrote:
>>>>>
>>>>>> Hi John,
>>>>>>
>>>>>> the file you linking is not accessible, please can you post
>>>>>> working
>>>>>> link, I'd like to read it.
>>>>>>
>>>>>> How do you want to support blending in non-premultiplied
>>>>>> colorspace?
>>>>>> I'm doing this in Fog library and only way to get this working is
>>>>>> premultiply, do blending, demultiply - quite slow.
>>>>>>
>>>>>> Thanks
>>>>>> - Petr
>>>>>>
>>>>>> 2009/8/17 John Horigan <john@...>:
>>>>>>>
>>>>>>> For my digital art program, Context Free, I have been using a
>>>>>>> modified
>>>>>>> form
>>>>>>> of the RGBA, RGB, and gray pixel formats. I do this because stock
>>>>>>> AGG is
>>>>>>> slightly inaccurate in computing and blending colors.  My changes
>>>>>>> to AGG
>>>>>>> are
>>>>>>> based on Alvy Ray Smith's paper on fast, accurate color
>>>>>>> blending (ftp://ftp.alvyray.com/Acrobat/4_Comp.pdf).
>>>>>>> The changes that I have made are:
>>>>>>> * Utility methods have been added to classes rgb8, rgb16, gray8,
>>>>>>> and
>>>>>>> gray16
>>>>>>> for doing fast, accurate fixed point multiplies and linear
>>>>>>> interpolations.
>>>>>>> * The add, gradient, and premultiply methods of classes rgb8,
>>>>>>> rgb16,
>>>>>>> gray8,
>>>>>>> and gray16 use the new utility methods.
>>>>>>> * multiplier_rgba<>::premultiply() method in agg_pixfmt_rgba.h
>>>>>>> uses the
>>>>>>> new
>>>>>>> utility methods.
>>>>>>> * All of the blender classes in agg_pixfmt_gray/rbg/rgba.h use
>>>>>>> the new
>>>>>>> utility methods.
>>>>>>> * The interface between these blender classes and the pixfmt
>>>>>>> classes has
>>>>>>> been changed slightly. Currently the pixfmt class multiplies the
>>>>>>> color
>>>>>>> alpha
>>>>>>> with pixel coverage factor before calling the blender (even
>>>>>>> though both
>>>>>>> alpha and cover are passed to the blender). With this patch, this
>>>>>>> calculation is moved to the blender class blend_pix() methods.
>>>>>>> * I added a utility method to class rect_base in agg_basics.h:
>>>>>>> overlaps()
>>>>>>> I have been using most of these changes for over a year in
>>>>>>> Context Free
>>>>>>> and
>>>>>>> I am confident in their correctness. I don't use the non-
>>>>>>> premultiplied
>>>>>>> color
>>>>>>> blenders but I was able to tweak Context Free to use them and
>>>>>>> they
>>>>>>> appeared
>>>>>>> to function correctly.
>>>>>>> The composition operation classes comp_op_rgba_x in
>>>>>>> agg_pixfmt_rgba.h and
>>>>>>> the pixfmt_custom_blend_rgba class that uses them have not been
>>>>>>> updated
>>>>>>> to
>>>>>>> use the new utility methods. The composition operators could
>>>>>>> stand to be
>>>>>>> implemented more accurately, but I don't have any test bench for
>>>>>>> validating
>>>>>>> changes.
>>>>>>> The patch can be found at
>>>>>>> http://www.ozonehouse.com/john/agg24_alvyraysmith.patch
>>>>>>> -- john
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Let Crystal Reports handle the reporting - Free Crystal Reports
>>>>>>> 2008
>>>>>>> 30-Day
>>>>>>> trial. Simplify your report design, integration and deployment -
>>>>>>> and
>>>>>>> focus
>>>>>>> on
>>>>>>> what you do best, core application coding. Discover what's new
>>>>>>> with
>>>>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>>>>> _______________________________________________
>>>>>>> Vector-agg-general mailing list
>>>>>>> Vector-agg-general@...
>>>>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Let Crystal Reports handle the reporting - Free Crystal Reports
>>>>>> 2008
>>>>>> 30-Day
>>>>>> trial. Simplify your report design, integration and deployment -
>>>>>> and focus
>>>>>> on
>>>>>> what you do best, core application coding. Discover what's new
>>>>>> with
>>>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>>>> _______________________________________________
>>>>>> Vector-agg-general mailing list
>>>>>> Vector-agg-general@...
>>>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Let Crystal Reports handle the reporting - Free Crystal Reports
>>>>> 2008 30-Day
>>>>> trial. Simplify your report design, integration and deployment -
>>>>> and focus
>>>>> on
>>>>> what you do best, core application coding. Discover what's new with
>>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>>> _______________________________________________
>>>>> Vector-agg-general mailing list
>>>>> Vector-agg-general@...
>>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>>>
>>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>>> 30-Day
>>>> trial. Simplify your report design, integration and deployment - and
>>>> focus on
>>>> what you do best, core application coding. Discover what's new with
>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>> _______________________________________________
>>>> Vector-agg-general mailing list
>>>> Vector-agg-general@...
>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports
>>> 2008 30-Day
>>> trial. Simplify your report design, integration and deployment -
>>> and focus on
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> _______________________________________________
>>> Vector-agg-general mailing list
>>> Vector-agg-general@...
>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> 30-Day
>> trial. Simplify your report design, integration and deployment - and
>> focus on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Vector-agg-general mailing list
>> Vector-agg-general@...
>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: Patch to improve blending accuracy of RGBA/RGB/Gray pixel formats

by John Horigan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK. This is a great idea, but I think it is a separate patch.

I have an idea for generalizing this double-blend technique and the  
SSE work that other people are doing. Let's extend the blender class  
to have a multi-pixel blend_pix method and an enum that defines how  
many pixels blend_pix_multi blends. The pixfmt class would use  
blend_pix to blend individual pixels and blend_pix_multi to blend  
aligned blocks of pixels. The default implementation would use various  
permutations of the double-blend technique, but SSE versions could be  
written too.

-- john

On Aug 17, 2009, at 11:24 AM, Petr Kobalíček wrote:

> on 64 bit cpu there will be benefit, but using 64 bit types on 32 bit
> cpu means usually slow-down. But you can use 64-bit integer to blend 4
> 8-bit integers.
>
> for example I'm using this inline function in Fog:
>
> // x_c = (x_c * a) / 255
> static FOG_INLINE uint32_t bytemul(uint32_t x, uint32_t a)
> {
> #if FOG_ARCH_BITS == 64
>  uint64_t x0 = ((uint64_t)x | ((uint64_t)x << 24)) &
> FOG_UINT64_C(0x00FF00FF00FF00FF);
>  x0 *= a;
>  x0 = (x0 + ((x0 >> 8) & FOG_UINT64_C(0x00FF00FF00FF00FF)) +
> FOG_UINT64_C(0x0080008000800080)) >> 8;
>  x0 &= FOG_UINT64_C(0x00FF00FF00FF00FF);
>  return (uint32_t)(x0 | (x0 >> 24));
> #else
>  uint32_t t0 = ((x & 0x00FF00FF)     ) * a;
>  uint32_t t1 = ((x & 0xFF00FF00) >> 8) * a;
>
>  x  = ((t0 + ((t0 >> 8) & 0x00FF00FF) + 0x00800080) >> 8) &  
> 0x00FF00FF;
>  x |= ((t1 + ((t1 >> 8) & 0x00FF00FF) + 0x00800080)     ) &  
> 0xFF00FF00;
>
>  return x;
> #endif
> }
>
> it multiplies each bit in 'x' by 'a' and then divides each bit by 255
> (using equal method described in paper you linked).
>
> I think that there is problem that pixel formats are hard to
> generalize (generalization usually means to degrade performance)
>
> 2009/8/17 John Horigan <john@...>:
>> What about rgba16 pixels? Wouldn't we have to generalize the double-
>> blend trick to use 32-bit math on 8-bit color channels and 64-bit  
>> math
>> on 16-bit color channels?
>>
>> -- john
>>
>> On Aug 17, 2009, at 8:53 AM, Petr Kobalíček wrote:
>>
>>> I know this paper, it's good explanation.
>>>
>>> I read your code and there is one possibility to improve speed by
>>> using double-blend trick. It's used by pixman library and I'm  
>>> using it
>>> in Fog. This trick is used to multiply two unsigned 8 bit integers
>>> packed in one 32 bit integer.
>>>
>>> Best regards
>>> - Petr
>>>
>>> 2009/8/17 John Horigan <john@...>:
>>>> OK. I can host that too.
>>>>
>>>> http://www.ozonehouse.com/john/4_Comp.pdf
>>>>
>>>> -- john
>>>>
>>>>
>>>> On Aug 17, 2009, at 8:26 AM, Petr Kobalíček wrote:
>>>>
>>>>> Hi John,
>>>>>
>>>>> thanks, but I talked about the pdf document :-) But I will study  
>>>>> you
>>>>> path too :)
>>>>>
>>>>> 2009/8/17 John Horigan <john@...>:
>>>>>> OK. I avoided posting the patch because it is larger than 50k.  
>>>>>> But
>>>>>> here is a
>>>>>> gzipped copy of it.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> -- john
>>>>>>
>>>>>>
>>>>>> On Aug 17, 2009, at 4:44 AM, Petr Kobalíček wrote:
>>>>>>
>>>>>>> Hi John,
>>>>>>>
>>>>>>> the file you linking is not accessible, please can you post
>>>>>>> working
>>>>>>> link, I'd like to read it.
>>>>>>>
>>>>>>> How do you want to support blending in non-premultiplied
>>>>>>> colorspace?
>>>>>>> I'm doing this in Fog library and only way to get this working  
>>>>>>> is
>>>>>>> premultiply, do blending, demultiply - quite slow.
>>>>>>>
>>>>>>> Thanks
>>>>>>> - Petr
>>>>>>>
>>>>>>> 2009/8/17 John Horigan <john@...>:
>>>>>>>>
>>>>>>>> For my digital art program, Context Free, I have been using a
>>>>>>>> modified
>>>>>>>> form
>>>>>>>> of the RGBA, RGB, and gray pixel formats. I do this because  
>>>>>>>> stock
>>>>>>>> AGG is
>>>>>>>> slightly inaccurate in computing and blending colors.  My  
>>>>>>>> changes
>>>>>>>> to AGG
>>>>>>>> are
>>>>>>>> based on Alvy Ray Smith's paper on fast, accurate color
>>>>>>>> blending (ftp://ftp.alvyray.com/Acrobat/4_Comp.pdf).
>>>>>>>> The changes that I have made are:
>>>>>>>> * Utility methods have been added to classes rgb8, rgb16,  
>>>>>>>> gray8,
>>>>>>>> and
>>>>>>>> gray16
>>>>>>>> for doing fast, accurate fixed point multiplies and linear
>>>>>>>> interpolations.
>>>>>>>> * The add, gradient, and premultiply methods of classes rgb8,
>>>>>>>> rgb16,
>>>>>>>> gray8,
>>>>>>>> and gray16 use the new utility methods.
>>>>>>>> * multiplier_rgba<>::premultiply() method in agg_pixfmt_rgba.h
>>>>>>>> uses the
>>>>>>>> new
>>>>>>>> utility methods.
>>>>>>>> * All of the blender classes in agg_pixfmt_gray/rbg/rgba.h use
>>>>>>>> the new
>>>>>>>> utility methods.
>>>>>>>> * The interface between these blender classes and the pixfmt
>>>>>>>> classes has
>>>>>>>> been changed slightly. Currently the pixfmt class multiplies  
>>>>>>>> the
>>>>>>>> color
>>>>>>>> alpha
>>>>>>>> with pixel coverage factor before calling the blender (even
>>>>>>>> though both
>>>>>>>> alpha and cover are passed to the blender). With this patch,  
>>>>>>>> this
>>>>>>>> calculation is moved to the blender class blend_pix() methods.
>>>>>>>> * I added a utility method to class rect_base in agg_basics.h:
>>>>>>>> overlaps()
>>>>>>>> I have been using most of these changes for over a year in
>>>>>>>> Context Free
>>>>>>>> and
>>>>>>>> I am confident in their correctness. I don't use the non-
>>>>>>>> premultiplied
>>>>>>>> color
>>>>>>>> blenders but I was able to tweak Context Free to use them and
>>>>>>>> they
>>>>>>>> appeared
>>>>>>>> to function correctly.
>>>>>>>> The composition operation classes comp_op_rgba_x in
>>>>>>>> agg_pixfmt_rgba.h and
>>>>>>>> the pixfmt_custom_blend_rgba class that uses them have not been
>>>>>>>> updated
>>>>>>>> to
>>>>>>>> use the new utility methods. The composition operators could
>>>>>>>> stand to be
>>>>>>>> implemented more accurately, but I don't have any test bench  
>>>>>>>> for
>>>>>>>> validating
>>>>>>>> changes.
>>>>>>>> The patch can be found at
>>>>>>>> http://www.ozonehouse.com/john/agg24_alvyraysmith.patch
>>>>>>>> -- john
>>>>>>>>
>>>>>>>>
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> Let Crystal Reports handle the reporting - Free Crystal Reports
>>>>>>>> 2008
>>>>>>>> 30-Day
>>>>>>>> trial. Simplify your report design, integration and  
>>>>>>>> deployment -
>>>>>>>> and
>>>>>>>> focus
>>>>>>>> on
>>>>>>>> what you do best, core application coding. Discover what's new
>>>>>>>> with
>>>>>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>>>>>> _______________________________________________
>>>>>>>> Vector-agg-general mailing list
>>>>>>>> Vector-agg-general@...
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Let Crystal Reports handle the reporting - Free Crystal Reports
>>>>>>> 2008
>>>>>>> 30-Day
>>>>>>> trial. Simplify your report design, integration and deployment -
>>>>>>> and focus
>>>>>>> on
>>>>>>> what you do best, core application coding. Discover what's new
>>>>>>> with
>>>>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>>>>> _______________________________________________
>>>>>>> Vector-agg-general mailing list
>>>>>>> Vector-agg-general@...
>>>>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Let Crystal Reports handle the reporting - Free Crystal Reports
>>>>>> 2008 30-Day
>>>>>> trial. Simplify your report design, integration and deployment -
>>>>>> and focus
>>>>>> on
>>>>>> what you do best, core application coding. Discover what's new  
>>>>>> with
>>>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>>>> _______________________________________________
>>>>>> Vector-agg-general mailing list
>>>>>> Vector-agg-general@...
>>>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>>>>
>>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Let Crystal Reports handle the reporting - Free Crystal Reports  
>>>>> 2008
>>>>> 30-Day
>>>>> trial. Simplify your report design, integration and deployment -  
>>>>> and
>>>>> focus on
>>>>> what you do best, core application coding. Discover what's new  
>>>>> with
>>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>>> _______________________________________________
>>>>> Vector-agg-general mailing list
>>>>> Vector-agg-general@...
>>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Let Crystal Reports handle the reporting - Free Crystal Reports
>>>> 2008 30-Day
>>>> trial. Simplify your report design, integration and deployment -
>>>> and focus on
>>>> what you do best, core application coding. Discover what's new with
>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>> _______________________________________________
>>>> Vector-agg-general mailing list
>>>> Vector-agg-general@...
>>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> 30-Day
>>> trial. Simplify your report design, integration and deployment - and
>>> focus on
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> _______________________________________________
>>> Vector-agg-general mailing list
>>> Vector-agg-general@...
>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports  
>> 2008 30-Day
>> trial. Simplify your report design, integration and deployment -  
>> and focus on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Vector-agg-general mailing list
>> Vector-agg-general@...
>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008  
> 30-Day
> trial. Simplify your report design, integration and deployment - and  
> focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: Patch to improve blending accuracy of RGBA/RGB/Gray pixel formats

by Udo Giacomozzi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi John,

does your patch also improve blending accuracy when using 15 or 16 bit
("hicolor") formats? We experience noticeable artifacts in those modes
in Gnash...  

Udo


Monday, August 17, 2009, 8:36:17 AM, you wrote:


For my digital art program, Context Free, I have been using a modified form of the RGBA, RGB, and gray pixel formats. I do this because stock AGG is slightly inaccurate in computing and blending colors.  My changes to AGG are based on Alvy Ray Smith's paper on fast, accurate color blending (ftp://ftp.alvyray.com/Acrobat/4_Comp.pdf).

The changes that I have made are:
* Utility methods have been added to classes rgb8, rgb16, gray8, and gray16 for doing fast, accurate fixed point multiplies and linear interpolations.
* The add, gradient, and premultiply methods of classes rgb8, rgb16, gray8, and gray16 use the new utility methods.
* multiplier_rgba<>::premultiply() method in agg_pixfmt_rgba.h uses the new utility methods.
* All of the blender classes in agg_pixfmt_gray/rbg/rgba.h use the new utility methods.
* The interface between these blender classes and the pixfmt classes has been changed slightly. Currently the pixfmt class multiplies the color alpha with pixel coverage factor before calling the blender (even though both alpha and cover are passed to the blender). With this patch, this calculation is moved to the blender class blend_pix() methods.
* I added a utility method to class rect_base in agg_basics.h: overlaps()

I have been using most of these changes for over a year in Context Free and I am confident in their correctness. I don't use the non-premultiplied color blenders but I was able to tweak Context Free to use them and they appeared to function correctly.

The composition operation classes comp_op_rgba_x in agg_pixfmt_rgba.h and the pixfmt_custom_blend_rgba class that uses them have not been updated to use the new utility methods. The composition operators could stand to be implemented more accurately, but I don't have any test bench for validating changes.

The patch can be found at http://www.ozonehouse.com/john/agg24_alvyraysmith.patch

-- john






------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: Patch to improve blending accuracy of RGBA/RGB/Gray pixel formats

by John Horigan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The patch does not fix the 15/16 bit formats. The patch is based on  
the theory in Alvy Ray Smith's paper:
http://www.ozonehouse.com/john/4_Comp.pdf

It shouldn't be too hard to adapt this work to 5 or 6-bit color  
components.

-- john

On Oct 2, 2009, at 4:21 AM, Udo Giacomozzi wrote:

> Hi John,
>
> does your patch also improve blending accuracy when using 15 or 16 bit
> ("hicolor") formats? We experience noticeable artifacts in those modes
> in Gnash...
>
> Udo
>
>
> Monday, August 17, 2009, 8:36:17 AM, you wrote:
>
>
> For my digital art program, Context Free, I have been using a  
> modified form of the RGBA, RGB, and gray pixel formats. I do this  
> because stock AGG is slightly inaccurate in computing and blending  
> colors.  My changes to AGG are based on Alvy Ray Smith's paper on  
> fast, accurate color blending (ftp://ftp.alvyray.com/Acrobat/4_Comp.pdf
> ).
>
> The changes that I have made are:
> * Utility methods have been added to classes rgb8, rgb16, gray8, and  
> gray16 for doing fast, accurate fixed point multiplies and linear  
> interpolations.
> * The add, gradient, and premultiply methods of classes rgb8, rgb16,  
> gray8, and gray16 use the new utility methods.
> * multiplier_rgba<>::premultiply() method in agg_pixfmt_rgba.h uses  
> the new utility methods.
> * All of the blender classes in agg_pixfmt_gray/rbg/rgba.h use the  
> new utility methods.
> * The interface between these blender classes and the pixfmt classes  
> has been changed slightly. Currently the pixfmt class multiplies the  
> color alpha with pixel coverage factor before calling the blender  
> (even though both alpha and cover are passed to the blender). With  
> this patch, this calculation is moved to the blender class blend_pix
> () methods.
> * I added a utility method to class rect_base in agg_basics.h:  
> overlaps()
>
> I have been using most of these changes for over a year in Context  
> Free and I am confident in their correctness. I don't use the non-
> premultiplied color blenders but I was able to tweak Context Free to  
> use them and they appeared to function correctly.
>
> The composition operation classes comp_op_rgba_x in  
> agg_pixfmt_rgba.h and the pixfmt_custom_blend_rgba class that uses  
> them have not been updated to use the new utility methods. The  
> composition operators could stand to be implemented more accurately,  
> but I don't have any test bench for validating changes.
>
> The patch can be found at http://www.ozonehouse.com/john/agg24_alvyraysmith.patch
>
> -- john
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart  
> your
> developing skills, take BlackBerry mobile applications to market and  
> stay
> ahead of the curve. Join us from November 9-12, 2009. Register  
> now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general