简体   繁体   中英

How to calculate inverse of hard-light composite blend mode?

I have an 'old' RGBA canvas on the client and a newer version of the same image on the server. There are small visual differences between them.

I want to be able for the server to send to the client some 'diff' to be able to update it's image to match the new version, without having to send the whole image data again.

A two-frame transparent webm video would be ideal (ie. use webm to encode the differences), but hardware support for webm with transparency is abysmal, and browser support for extracting a specific frame from a video is also very poor.

Instead I am looking at using the hard light blend mode, which should allow me to send a single image to the client, and have any RGBA pixel converted to any other (with a margin of error of 1).

How should I generate the difference image though? Which combination of blend modes can generate diff if new = hardlight(old, diff)

Let Ch, Cw, Cd be the value you have, the value you want, and the diff value:

if (Cw > Ch)
    Cd = 1 - (1-Cw)/2(1-Ch)
else if (Cw < Ch)
    Cd = Cw/2Ch
else
    Cd = 0.5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM