亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

AGG第四十二課 Blitting an image over another with transparency

發布時間:2020-06-17 23:58:02 來源:網絡 閱讀:514 作者:fengyuzaitu 欄目:系統運維


問題:

I've managed to blit a loaded p_w_picpath onto another through the method 

"copy_from(...)" of renderer_base.

I'd like to know how can i blit the same p_w_picpath and also specifying a color 

that will NOT overwrite the pixels of the destination p_w_picpath ( a color that 

will then result transparent ).

I complete my question by specifying that the source p_w_picpath is a BMP and 

therefore doesn't support transparency and alpha channel in the pixel 

values.

Any suggestion is appreciated

回答:

Yes, your simple question isn't actually that simple. I could add this 

functionality to copy_from, but I don't know what exactly to add. Do you 

need to make transparent only one color? Or a number of colors? Or maybe it 

should be some volume in RGB with transparency determined by the distance 

from a certain point. OK, suppose you need only one color, bu someone else 

may want to make a number of colors translucent. And so on. We need a kind 

of a general solution.


For now you can try to use a method similar to the one in 

examples/p_w_picpath_alpha.cpp

See class span_conv_brightness_alpha_rgb8 and modify it as you want.

But it's a transformer, so that, works slower than copy_from. Besides, with 

any kind of a filter (bilinear and such) the colors are not exact, so, it's 

probably makes sense to use span_p_w_picpath_filter_rgb_nn instead of 

span_p_w_picpath_filter_rgb_bilinear.


Maybe it makes sense to add some functor to copy_from(), but I have no idea 

how to do that in a general way and without losing performance. Perhaps 

there should be another function more like blend_from(). Any ideas?

答復:

Actually I've gone for a "specialized" solution, that just solves my case. 

In detail, I created a new renderer that's only suitable to copy bitmaps one 

over another with 1 transparent color.

I only have ported the "copy_from" method from renderer_base along with all 

the clipping helper methods and obejcts of your original rendere_base.

I added a method that sets a trasparency color:


    setTransaprentColor(color_type color)

    {

        ...

    }


In the "copy_from" method, I get the color of the source bitmap with the 

"pixel(x,y)" method, check it against "transparentColor" and, if equal, I 

simply skip the point with a "continue" statement.

Else, I call "copy_pixel" on the underlying rendering_buffer with the exact 

value of the source bitmap pixel.


It's evident that it can be easily extended to a generic "array" of 

transparent colors, with the cost of cycling through all of them to see if 

one of them matches the source color. Even better, one could even imagine to 

"map" some source color with some other colors (along with its own alpha 

channel) once the source RGB values are matched against the RGB values of 

the "transformer" object. I thought about it and it is not difficult to code 

such a transformer object and pass it to a renderer. But that would be too 

much for my special case and also kind of "expensive" in terms of 

performance, so I just left it "for future expansions" ;-)


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

墨竹工卡县| 焦作市| 自贡市| 广丰县| 楚雄市| 夏河县| 南宫市| 定远县| 高密市| 常熟市| 北宁市| 睢宁县| 华坪县| 紫金县| 鄂托克前旗| 苏尼特左旗| 鲜城| 遵义市| 永定县| 吴桥县| 林西县| 彭阳县| 永修县| 库尔勒市| 滨州市| 彭水| 蒙城县| 攀枝花市| 乐都县| 井陉县| 辰溪县| 甘肃省| 喀喇沁旗| 柳河县| 普兰店市| 贡觉县| 富民县| 瑞丽市| 梧州市| 洱源县| 五莲县|