byte

Custom byte size?

旧街凉风 提交于 2019-12-07 03:48:09
问题 So, you know how the primitive of type char has the size of 1 byte? How would I make a primitive with a custom size? So like instead of an in int with the size of 4 bytes I make one with size of lets say 16. Is there a way to do this? Is there a way around it? 回答1: Normally you'd just make a struct that represents the data in which you're interested. If it's 16 bytes of data, either it's an aggregate of a number of smaller types or you're working on a processor that has a native 16-byte

How can I reverse the byte order of an NSInteger or NSUInteger in objective-c

时间秒杀一切 提交于 2019-12-07 02:54:38
问题 This is a somewhat of a follow up to this posting but with a different question so I felt I should ask in a separate thread. I am at the point where I have four consecutive bytes in memory that I have read in from a file. I'd like to store these as a bit array (the actual int value of them does not matter until later). When I print out what is in my int, I notice that it seems to be stored in reverse order (little endian). Does anyone have a good method for reversing the order of the bytes.

'Stride' Woes from a TransformedBitmap Object

寵の児 提交于 2019-12-07 01:23:18
问题 I have a 2208 x 3000 TransformedBitmap object with format {Indexed8} that I'm do .CopyPixels() on. I'm using (int)((formattedBitmap.PixelWidth * formattedBitmap.Format.BitsPerPixel + 7) / 8) (assuming 'formattedBitmap' is the name of the image from which I'm trying to copy the pixels) for the 'stride' value in my method call and an array of bytes which is 2208 in length. I have something just like this working elsewhere in the code (where the format of the image is {Gray8}. However, where I'm

Load, show, convert image from byte array (database) in Windows Phone 8.1

匆匆过客 提交于 2019-12-07 01:00:35
问题 The full question is how to show image loaded from database in windows phone 8.1. Image data is loaded as byte array (checked - loads fine). Displaying image by specifying urisource works fine. Image img = new Image(); img.Source = new BitmapImage() {UriSource = new Uri("http://www.example.com/1.jpg") }; rootgrid.Children.Add(img); But when byte array (of image) is converted to BitmapImage - nothing is shown. The only exception free example I'v found so far is: public BitmapImage

Java - Byte[] to byte[]

自作多情 提交于 2019-12-06 19:03:07
问题 There is Vector and DataOutputStream. I need to write bytes from Vector (toArray returns Byte[]) to the stream, but it understands byte[] only. How to convert Byte[] to byte[] ? 回答1: You could use the toPrimitive method in the Apache Commons lang library ArrayUtils class? 回答2: byte[] toPrimitives(Byte[] oBytes) { byte[] bytes = new byte[oBytes.length]; for(int i = 0; i < oBytes.length; i++) { bytes[i] = oBytes[i]; } return bytes; } Inverse: // byte[] to Byte[] Byte[] toObjects(byte[]

Using char as an unsigned 16 bit value in Java?

那年仲夏 提交于 2019-12-06 16:29:15
I need an unsigned 8 bit integer in Java, and char seems to be the only thing close to that. Although it's double the size, it's unsigned which makes it practical for what I want to use it for (writing a basic emulator which requires unsigned bytes). The problem is that I've heard other programmers say that one shouldn't use char in that manner and should just use int or so. Is this true, and why so? If you need an unsigned 8 bit integer then use byte . It's easy to make it unsigned in arithemtic operations (where actually sign matters) as byteValue & 0xFF In Java: long: [-2^63 , 2^63 - 1] int

Exploit development in Python 3

試著忘記壹切 提交于 2019-12-06 16:21:17
问题 This question was migrated from Information Security Stack Exchange because it can be answered on Stack Overflow. Migrated 2 years ago . I realised that exploit development with python 3 is not as straight forward as it is using python 2. As I understand, this is mainly due to the socket library and the added byte datatype. For example, I could not figure out how to translate the following code into Python 3 code: --- SNIP --- shellcode = "" shellcode += "\x89\xe2\xd9\xcf\xd9\x72\xf4\x5a\x4a

Reading bytes one by one from binary file

谁都会走 提交于 2019-12-06 15:09:17
问题 this is my question, i want to open a .jpg file and write each byte as a decimal number (0-255) separated with a comma, into another .txt file. now it should be able to build the .jpf file again using that txt file. this is how i tried to do it. #include<iostream> #include<fstream> using namespace std; int main() { long x; char *s; ifstream ifs("image.jpg",ios::binary); ifs.seekg(0,ios::end); x=ifs.tellg(); ifs.seekg(0,ios::beg); s=new char[x]; ifs.read(s,x); ifs.close(); ofstream is("image

Understanding of the Audio Recorder read() buffer [closed]

≯℡__Kan透↙ 提交于 2019-12-06 15:00:06
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I really hope someone could help me. I am currently working with the Android "Audio Recorder" and everything works fine. The next step would be to work with the bytes I got back from the buffer when I called read() . Being a Web Developer for quit some time, I lack some basics - mostly about the bytes stored in there. I would really like to understand, "what" the bytes are I got back from the method. It really

How to overwrite specific bytes in a binary file with C#?

北城以北 提交于 2019-12-06 14:54:37
问题 I want to overwrite bytes in an exe. So I need to generate a random string, convert it, and then write it to the exe. I need to overwrite the 4 hex strings you see there in this format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12) the dashes are needed so that also was a problem for me. this is the location of the first string. I absolutely got no idea how to start this, how I can overwrite these 4 strings, in the correct format with random strings (hex, so the random can only be