简体   繁体   English

未知代码片段-0xff000000

[英]Unknown code fragment - 0xff000000

I came across this program under hough transform in java example. 我在java示例中的hough转换下遇到了这个程序。 But im doing my project in C#, i cannot figure out what is ment by this partial code " 0xff000000 ". 但是我正在用C#执行我的项目,我无法弄清楚此部分代码“ 0xff000000 ”的含义。 what this piece of code - 0xff000000 is it a color? 这段代码是什么-0xff000000是一种颜色? if its color how can i convert it C#? 如果其颜色如何将其转换为C#?

private void drawPolarLine(int value, int r, int theta) {
            for(int x=0;x<width;x++) {

                for(int y=0;y<height;y++) {

                        int temp = (int)(x*Math.cos(((theta)*Math.PI)/180) + y*Math.sin(((theta)*Math.PI)/180));
                    if((temp - r) == 0)
                         output[y*width+x] = 0xff000000 | (value << 16 | value << 8 | value);

                }
            }
        }

if ((input[y*width+x] & 0xff)== 255) {
    //.........
}

it's just the HEX representation of a number. 它只是数字的十六进制表示。 0xF=15, 0xF0=240, 0xFF=255, 0xF12A=61738, ...., 0xff000000=4278190080 0xF = 15,0xF0 = 240,0xFF = 255,0xF12A = 61738,....,0xff000000 = 4278190080

It's easier to understand and more meaningful in coding when you're doing bitwise operations 当您执行按位运算时,它更易于理解,并且在编码中更有意义

In RGBA notation, the leftmost byte is generally the alpha channel. 在RGBA表示法中,最左边的字节通常是alpha通道。 It indicates the amount of transparency of a given pixel. 它指示给定像素的透明度。 0x00 is for a fully transparent pixel, and 0xff for a fully opaque one (as if, no transparency at all.) 0x00表示完全透明的像素,0xff表示完全不透明的像素(好像完全不透明)。

See http://en.wikipedia.org/wiki/RGBA_color_space . 参见http://en.wikipedia.org/wiki/RGBA_color_space

The hexadecimal number 0xFF000000 is expressed in dot-decimal notation as 255.0.0.0. 十六进制数0xFF000000以点十进制表示为255.0.0.0。 The digits 0 and 1 represent? 数字0和1代表什么?

A hex character does not normally represent a specific decimal character. 十六进制字符通常不表示特定的十进制字符。 It represents 4 bits in a Base 2 (Binary) number system. 在Base 2(二进制)数字系统中,它代表4位。 This is why dot-decimal notation is used for IP addresses. 这就是为什么IP地址使用点十进制表示法的原因。 It makes it more readable for a user because a Hex FF is ALWAYS used to represent a full octet of binary ones which can always be displayed as 255 in dot-decimal notation. 因为十六进制FF总是用来表示二进制八位字节的完整八位字节,因此始终以点十进制表示为255,因此它对于用户而言更具可读性。

Lets say you want to represent 1111 1111 0001 1111, you would use 0.0.255.31 in dot-decimal format even though FF1F in Hex is actually 65311 in a Base 10 (Decimal) number system. 假设您要表示1111 1111 0001 1111,即使在以10为底的十进制数字系统中,十六进制的FF1F实际上为65311,也将以点十进制格式使用0.0.255.31。

Hex ..........Decimal.......bin
0...............0..............0
1...............1..............1
2...............2..............10
3...............3..............11
4...............4..............100
5...............5..............101
6...............6..............110
7...............7..............111
8...............8.............1000
9...............9.............1001
A..............10............1010
B..............11............1011
C..............12............1100
D..............13............1101
E..............14............1110
F..............15............1111
10............16........0001 0000

The programming language Java does not provide you with pointers, so you can't access the memory location of objects/integers and other things. Java编程语言不为您提供指针,因此您无法访问对象/整数和其他东西的存储位置。 I'm not sure if c# does, but if you truly want to understand how memory locations work, I would learn a language like c++. 我不确定c#是否可以,但是如果您真的想了解内存位置的工作原理,我会学习类似c ++的语言。

The code 0xff000000 is just a hexadecimal representation of a number. 代码0xff000000只是数字的十六进制表示。 Specifically, the number 4,278,190,080. 具体而言,数字为4,278,190,080。 You can use it the same way in C#. 您可以在C#中以相同的方式使用它。

In this code, it probably represents a color, but it's hard to tell without knowing more about what you are doing. 在这段代码中,它可能代表一种颜色,但是如果不知道自己在做什么,就很难分辨出来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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