伪透明图像
对于大学作业,我们使用一种相当陌生的语言 Modula 2 进行编程,该语言缺乏主要的图形支持。
我想知道如何在图像上实现“透明”效果,我想它会像这样工作:
为图像的背景区域创建一个二维数组,填充该区域中不同像素的颜色,创建另一个二维数组图像再次具有每张图片的颜色,然后合并像素颜色并在适当的位置绘制不同的“新颜色”。
我想知道的是:如何合并颜色(十六进制)
( colour1 + colour2 ) / 2
:?
感谢您的帮助!!
For an assignment at university we program in a pretty unknown language Modula 2, which lacks major graphic support.
I was wondering how to achieve a 'transparency' effect on images, i figured it would work like this:
Create a 2D array for the background area of the image filled with the colours of the different pixels in that area, create another 2D array of the image with again the colours of every picture and than merge the pixel colours and draw the different "new colours" on their appropriate place.
What i was wondering about: how do i merge the colours (hexadecimals) just:
( colour1 + colour2 ) / 2
?
Thanks for your help!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,你不会对数字进行平均。
假设它们以这种形式存储:
那么由于颜色分量之间的溢出,平均会导致奇怪的事情发生。您想要做的是对每个单独的分量(即红色、绿色和蓝色)进行平均,然后将它们组合在一起。在伪代码中(抱歉我实际上不知道 modula-2):
No, you would not average the numbers.
Assuming they are stored in this form:
then averaging would make weird things happen because of the spillover between color components. What you want to do is average each individual component (i.e. red, green, and blue) and then combine them together. In pseudocode (sorry i don't actually know modula-2):