byte

Reading binary file bitwise in R

牧云@^-^@ 提交于 2019-12-24 15:26:02
问题 Since I am not a programmer I got stuck solving this probably trivial problem: I would like to extract numeric values from binary file (example.Lis) using R. First 256 bytes contain a header. I know the header structure therefore I was able to decode its content. For instance, according the format description, OLE DATE information is stored in bytes 8-15 as a double data type. To read this, I simply used following command: my.file = file("example.Lis", "rb") headall<-readBin(my.file, raw(), n

Java getting bytes of clipboard

怎甘沉沦 提交于 2019-12-24 14:00:04
问题 So I want to get the actual bytes of the user's clipboard. I can't find a way of doing this, all I find is how to get the clipboard as a String. To get the clipboard as a String, I'd have to do something like this: String data = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor); Help will be appreciated. 回答1: Once you have the String representation of the clipboard, you can get the bytes via String#getBytes(). byte[] clipboardBytes = clipboardString

Why does TStringStream.Bytes differ from what one gets from 'TStream.Read'

混江龙づ霸主 提交于 2019-12-24 12:34:01
问题 With TStringStream, the bytes using its Bytes property differs from the bytes extracted using TStream.Read . As shown below: the bytes extracted using TStream.Read represents correct data. the bytes using its Bytes property contains more data. (the last byte of correct bytes is different from that of wrong bytes ) Could you help to comment about the possible reason? Thank you very much for your help! PS: Delphi XE, Windows 7. (It seems TStringStream back in Delphi 7 doesn't have LoadFromFile

Conversion of a binary representation stored in a list of integers (little endian) into a Biginteger

不羁的心 提交于 2019-12-24 12:15:04
问题 I have a list of integers, say L which contains the binary representation of a number. Each integer in the list L can be 0 or 1. The "least significant bit" is on the left (not on the right). Example: 1000001111 for the (decimal) number 961, or 0111010001 for 558. I want to convert the list into a Biginteger. I have tried the following so far: Dim bytes(L.Count - 1) As Byte For i As Integer = 0 to L.Count - 1 bytes(i) = CByte(L(i)) Next Dim Value As New BigInteger(bytes) Return Value but the

Working with Byte literals

只谈情不闲聊 提交于 2019-12-24 12:13:03
问题 I'm using the following function to brighten up color values (it's a lambda in my code, but that shouldn't make a differende): Function ReduceDistanceTo255(ByVal i As Byte) As Byte Return i + (255 - i) \ 2 End Function It won't compile, since the compiler interprets 255 and 2 as integers rather than bytes, making the result of type Integer . Unfortunately, there is no Byte type character, so I cannot just write 255B or something like that. There are a few obvious workarounds to the problem:

How to convert binary String back to Byte in CSharp. Hex number created by SQL Server 2012 Varbinary(8)

拥有回忆 提交于 2019-12-24 12:12:17
问题 I am trying to convert a String Hex number back into a Byte() in CSharp & I just can't do it! These Binary numbers are stored in a varBinary(8) column inside Sql Server 2012. A format example is : 0x000000003B654362 I have no problem geting them from the database & turning them into a String. But when I want to query the database using this Hex number as a key I want to turn the String back into a cSharp Byte type. I get an error "Input String is not in correct format" everytime I try to use

How do I prevent a memory leak with UIImage.FromImage(context.ToImage())?

社会主义新天地 提交于 2019-12-24 10:40:40
问题 I have the following function to convert a byte array of pixels into an image. However, I have a memory leak in the line: unpackedImage = UIImage.FromImage(context.ToImage()); When I comment out the line above, the leak goes away. The leak is so bad that iOS is killing my app within about 30 seconds of startup. It's because of this line of code. How do I prevent this memory leak? Is there a better way to do what I am trying to do? public static void DrawCustomImage2(IntPtr buffer, int width,

Discover the character encoding from byte

喜夏-厌秋 提交于 2019-12-24 10:27:58
问题 I have a string where I know that the degree symbol (°) is represented by the byte 63 (3F). Each character is represented by a single byte. How can I find the character encoding used ? 回答1: Almost all 8-bit encodings in modern times coincide with ASCII in the ASCII range, so byte 3F hexadecimal is the question mark “?”. As Sebtm’s comment suggests, this might result from character-level data error. E.g., some software that is limited to ASCII could turn all other bytes to “?” – not a good

Java - CRC32.update() on concatenated ByteBuffer

China☆狼群 提交于 2019-12-24 09:25:26
问题 I have the following function: byte[] test1 = {1,2,3,4}; byte[] test2 = {5,6,7,8}; ByteBuffer bbtest1 = ByteBuffer.wrap(test1).order(ByteOrder.LITTLE_ENDIAN); ByteBuffer bbtest2= ByteBuffer.wrap(test2).order(ByteOrder.LITTLE_ENDIAN); ByteBuffer contents = ByteBuffer.allocate(bbtest1.limit() + bbtest2.limit()); contents.put(bbtest1); contents.put(bbtest2); CRC32 checksum = new CRC32(); checksum.update(contents); System.out.println(checksum.getValue()); No matter what values I assign my byte

Xamarin Forms - Image to String and reverse

青春壹個敷衍的年華 提交于 2019-12-24 08:15:06
问题 I saw so much of post on google and I couldn't make it works. However, it seems so easy and logic to get an Xamarin.Forms.Image into a String but I'm not able to realize it. I tried from stream, from platform renderer, still doesn't work. I want it to work on every platform, can you help me? Thank ! 回答1: if what you want is a string representation of a Image then first you need to get the bytes from this image and then convert it into a string format like Base64 But first we need to get the