binary

Streaming binary data from Google Cloud Storage to Cloud Function

坚强是说给别人听的谎言 提交于 2021-02-11 13:26:51
问题 I have some large binary files stored in Google Cloud Storage that require byte by byte processing. I would like to do this processing using a Cloud Function, but this would require streaming the binary data through the cloud function. Does anybody have any idea how to do this. I'm using Python 3.7. 来源: https://stackoverflow.com/questions/60273469/streaming-binary-data-from-google-cloud-storage-to-cloud-function

confusion regarding range of char

回眸只為那壹抹淺笑 提交于 2021-02-11 12:36:01
问题 As we know that the range of char is -128 to 127 . The 2's compliment of -128 and the binary of 128 is same, which is 10000000 So why the range of char is -128 to 127 but not -127 to 128 . Where as in case of int , 128 and -128 both are different. 回答1: In twos-complement notation, whenever the high-order bit is 1, the number is negative. So the biggest positive number is 01111111 = 127 and the smallest negative number is 10000000 = -128 The same thing happens for int , but its range is much

Performant read uint12 binary from file in JavaScript

我与影子孤独终老i 提交于 2021-02-10 18:14:44
问题 I need to read a binary blob from file into a JavaScript array. The blob is little endian, uint 12 bit, I.e. --------------------------------- | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |-------------------------------| | data1[7:0] | |-------------------------------| | data2[3:0] | data1[11:8] | |-------------------------------| | data2[11:4] | --------------------------------- It seems like TypedArrays and bit shifting might be the best way (that's how I solved in Python), but I'm trying to make

How to convert a raw 64-byte binary to Hex or ASCII in C

北战南征 提交于 2021-02-10 16:17:49
问题 I´m using SHA512 in C to get an Hash-Value. I did it like this: #include <stdlib.h> #include <stdio.h> #include <openssl/sha.h> int main(int argc, char *argv[]){ unsigned char hash[SHA512_DIGEST_LENGTH]; char data[] = "data to hash"; //Test Data SHA512(data, sizeof(data) - 1, hash); //Kill termination character //Now there is the 64byte binary in hash I tried to convert it to hex by: long int binaryval, hexadecimalval = 0, i = 1, remainder; binaryval=(long int)hash; while (binaryval != 0) {

C++ reading binary files

。_饼干妹妹 提交于 2021-02-10 06:08:20
问题 I want to understand how does reading binary files work in C++. My code: int main() { ifstream ifd("input.png",ios::binary |ios::ate); int size = ifd.tellg(); ifd.seekg(0, ios::beg); vector<char> buffer; buffer.reserve(size); ifd.read(buffer.data(), size); cout << buffer.data(); return 0; } I thought that if I cout my buffer I would get the result in binary but that is not the case. My output is: ˙Ř˙á6Exif And if I read the text file it displays the text in normal form not in binary.

C++ reading binary files

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-10 06:03:23
问题 I want to understand how does reading binary files work in C++. My code: int main() { ifstream ifd("input.png",ios::binary |ios::ate); int size = ifd.tellg(); ifd.seekg(0, ios::beg); vector<char> buffer; buffer.reserve(size); ifd.read(buffer.data(), size); cout << buffer.data(); return 0; } I thought that if I cout my buffer I would get the result in binary but that is not the case. My output is: ˙Ř˙á6Exif And if I read the text file it displays the text in normal form not in binary.

Convert binary file to image

匆匆过客 提交于 2021-02-08 13:35:18
问题 I need to find a fast way to convert a binary file to an image. The binary file consist of a N N N matrix and I want to associate 0 to a color and 1 to a different color. I need to perform this operation to more then 1000 binary files. If possible I'd like to avoid using MatLab, is there any tool/software (for unix) that would help me? EDIT: This is exactly what I was looking for! On the bottom of the page it says: "TIP: To process many files, use a shell script to pass this URL and your

Most efficient way to save binary code to file

£可爱£侵袭症+ 提交于 2021-02-08 10:24:56
问题 I have a string that only contains 1 and 0 and I need to save this to a .txt-File. I also want it to be as small as possible. Since I have binary code, I can turn it into pretty much everything. Saving it as binary is not an option, since apparently every character will be a whole byte, even if it's a 1 or a 0 . I thought about turning my string into an Array of Byte but trying to convert "11111111" to Byte gave me a System.OverflowException . My next thought was using an ASCII Codepage or

Grayscale image from binary data

丶灬走出姿态 提交于 2021-02-08 08:58:22
问题 I'm working on some simple viewer app for CT images. Let's say I have array of 262144 Int16 values. Each value represents one pixel in 512x512 image. Each pixel has value from 0 to 4096 where 0 is black and 4096 is white. Is there any elegant, simple solution to display this image in Visual Studio Picture Box? Maybe some kind of MemoryReader or Stream? I've tried to search for some solution but found only topic about retrieving binary data from databases. 回答1: A good way and with a good

How can i check if binary file's content is found in other binary file?

大憨熊 提交于 2021-02-08 08:16:21
问题 i need to check if content in a binary file in in other binary file. i've tried to copy both files content into a array of chars with fread and check them with strstr, but strstr is always returning NULL even if the content supposed to be found in the other file. Any ideas? Thanks. 回答1: Since the strstr function won't work here for an arbitrary binary data (it is working only for strings with \0 . termination), I can see three approaches here: 1) Naive approach: iterate over one array of