byte

C++ LOBYTE .Please explain more?

人盡茶涼 提交于 2021-01-27 05:23:27
问题 i recently started learning c++ and assembly and i came across LOBYTE when i disassembled something in IDA and viewed the function in pseudo code. Reading the msdn : http://msdn.microsoft.com/en-us/library/windows/desktop/ms632658(v=vs.85).aspx i still dont understand.What is a low order byte? Can someone tell me more on what its used for and an example of its usage in c++ ? 回答1: LOBYTE and HIBYTE along with HIWORD and LOWORD , are macros used to extract a word or a byte from a larger set of

Best way to get two nibbles out of a byte in javascript?

Deadly 提交于 2021-01-20 16:33:41
问题 I'm parsing a binary file in javascript that is storing two pieces of information per byte, one per nibble. The values are, of course, 0-16 and 0-16. In all other parts of the file format, each byte represents one piece of information, so I have been using the following to successfully get the number values I need: var num = str.charCodeAt(0) & 0xFF; But I'm stuck at trying to figure out how to get the 0-16 value of the first nibble, and the same for the 2nd nibble from my single byte

Best way to get two nibbles out of a byte in javascript?

…衆ロ難τιáo~ 提交于 2021-01-20 16:31:15
问题 I'm parsing a binary file in javascript that is storing two pieces of information per byte, one per nibble. The values are, of course, 0-16 and 0-16. In all other parts of the file format, each byte represents one piece of information, so I have been using the following to successfully get the number values I need: var num = str.charCodeAt(0) & 0xFF; But I'm stuck at trying to figure out how to get the 0-16 value of the first nibble, and the same for the 2nd nibble from my single byte

DX下实现图片的遮罩(Mask)

独自空忆成欢 提交于 2021-01-17 18:26:39
虽然传统的用含遮罩信息的24bit图片来保存一个32bit的图像已经很少见了(以前的游戏比较常见),基本上随着png的流行,已经让32bit格式的图像普及网络以及游戏界了,当然更多的游戏采用dx原生支持的dds,或者可以自定义形状的更加灵活的tga格式等.不过这里还是介绍下在DX下Mask的实现,因为我的项目里涉及到可能要使用旧的游戏资源. 储存mask信息的图片: D3DLOCKED_RECT locked_rect; temp->tex->tex->LockRect(0, &locked_rect, NULL, 0); BYTE *pByte = (BYTE *) locked_rect.pBits; BYTE *pmaskByte = (BYTE *) locked_rect.pBits + width*4; int iOffset = locked_rect.Pitch/2; //偏移字节数 int i=0; for( int iRow=0; iRow<height; iRow++ ) { for( int iCol=0; iCol<width; iCol++ ) { masked_pixel_buf[i] = pByte[0]; masked_pixel_buf[i+1] = pByte[1]; masked_pixel_buf[i+2] = pByte[2];

How to `Serial.print()` “full” hexadecimal bytes?

橙三吉。 提交于 2020-12-26 06:32:16
问题 I am programming Arduino and I am trying to Serial.print() bytes in hexadecimal format "the my way" (keep reading for more information). That is, by using the following code byte byte1 = 0xA2; byte byte2 = 0x05; byte byte3 = 0x00; Serial.println(byte1, HEX); Serial.println(byte2, HEX); Serial.println(byte3, HEX); I get the following output in the Serial Monitor: A2 5 0 However I would like to output the following: A2 05 00 In words, I would like to print the "full" hexadecimal value including

What are Go's rules for comparing bytes with runes?

落花浮王杯 提交于 2020-12-25 03:59:42
问题 I've discovered the following peculiarity: b := "a"[0] r := 'a' fmt.Println(b == r) // Does not compile, cannot compare byte and rune fmt.Println("a"[0] == 'a') // Compiles and prints "true" How does this work? 回答1: This is an example of untyped constants. From the docs: Untyped boolean, numeric, and string constants may be used as operands wherever it is legal to use an operand of boolean, numeric, or string type, respectively. Except for shift operations, if the operands of a binary

What are Go's rules for comparing bytes with runes?

梦想与她 提交于 2020-12-25 03:58:33
问题 I've discovered the following peculiarity: b := "a"[0] r := 'a' fmt.Println(b == r) // Does not compile, cannot compare byte and rune fmt.Println("a"[0] == 'a') // Compiles and prints "true" How does this work? 回答1: This is an example of untyped constants. From the docs: Untyped boolean, numeric, and string constants may be used as operands wherever it is legal to use an operand of boolean, numeric, or string type, respectively. Except for shift operations, if the operands of a binary

What are Go's rules for comparing bytes with runes?

痞子三分冷 提交于 2020-12-25 03:58:26
问题 I've discovered the following peculiarity: b := "a"[0] r := 'a' fmt.Println(b == r) // Does not compile, cannot compare byte and rune fmt.Println("a"[0] == 'a') // Compiles and prints "true" How does this work? 回答1: This is an example of untyped constants. From the docs: Untyped boolean, numeric, and string constants may be used as operands wherever it is legal to use an operand of boolean, numeric, or string type, respectively. Except for shift operations, if the operands of a binary

What are Go's rules for comparing bytes with runes?

∥☆過路亽.° 提交于 2020-12-25 03:58:23
问题 I've discovered the following peculiarity: b := "a"[0] r := 'a' fmt.Println(b == r) // Does not compile, cannot compare byte and rune fmt.Println("a"[0] == 'a') // Compiles and prints "true" How does this work? 回答1: This is an example of untyped constants. From the docs: Untyped boolean, numeric, and string constants may be used as operands wherever it is legal to use an operand of boolean, numeric, or string type, respectively. Except for shift operations, if the operands of a binary

How to print out the contents of a PBYTE?

北慕城南 提交于 2020-12-15 05:38:06
问题 I understand PBYTE is unsigned char* from Windows Data Types. I want to be able to print all the contents, either using printf() or cout : PBYTE buffer; ULONG buffersize = NULL; serializeData(data, buffer, buffersize); //this function serializes "data" and stores the data in buffer and updates bufferSize).. Can you help me understand how to print this in C++? 回答1: If you want to print the memory address that buffer is pointing at, then you can do it like this: PBYTE buffer; ULONG buffersize =