如何在JAVA中添加或删除颜色?

问题描述:

你好,朋友们



我在VB.NET中有这个代码:





Hello, friends

I have this code in VB.NET:


Public Class MyClass
	Public Sub MyFunction()
		Dim c As System.Drawing.Color
		c = Color.Red
		c = c AND &hFFFFFFFF
	End Sub
End Class





此代码是为C变量添加Color,如何将其转换为C#或JAVA代码?

我试过这个:



This code is to add Color to c variable, how can I convert this to C# or JAVA Code?
I've tried this:

Color c = Color.Red;
        c = c & 0xFFFFFFFF;



但它没有用!!


but it did not worked!!

我看不出该行

I cannot see what the line
c = c AND &hFFFFFFFF



是这样做。 .NET Color结构没有定义按位运算符。

此外,取一个int值并在它和-1之间进行按位AND基本上返回相同的int值。



我的感觉是,这个代码已经被一个不了解它正在做什么的人从java-one中复制过来。此代码不会添加任何颜色;它尝试进行按位操作,使结果保持不变。



您可能必须准确定义您对此声明的期望。



问候。



纠正了关于按位AND事物的微小不精确性。


is doing. .NET Color structure does not have bitwise operators defined.
Moreover, taking an int value and making a bitwise-AND between it and -1 basically returns the same int value.

My feeling is that this code is already copied from a java-one by someone who is not understanding what it is doing. This code does not add anything to color; it tries to make a bitwise operation that leaves the result unchanged.

You may have to define precisely what you are expecting from this statement.

Regards.

Corrected a minor imprecision regarding the bitwise-AND stuff.