bytearray

How to convert 1D byte array to 2D byte array which holds a bitmap?

。_饼干妹妹 提交于 2019-12-12 09:56:46
问题 I have already used the LockBits and UnlockBits functions and takes the byte array of a Image into a 1D array. (considering only the black and white/binarized images) Is there any way of taking it to a 2D array (of the size image height and width)? so i can wirte the array into a ".txt" file and view it? The code i have used to take the image into 1D array is as below: Public void function(Bitmap image){ { byte[] arr1D; byte[] arr2D; BitmapData data = image.LockBits(new Rectangle(0, 0, img_w,

Null Pointer Exception when trying to compress Bitmap

↘锁芯ラ 提交于 2019-12-12 09:42:26
问题 I'm getting a null pointer exception when trying to compress a bitmap so I can send it to a ByteArrayOutputStream to get a byte array. I need this byte array so I can upload the image to my Parse database as a ParseFile. The log error is shown below. 01-11 23:29:41.522 32015-32015/com.example.whhsfbla.fashionnow E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.whhsfbla.fashionnow, PID: 32015 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics

Quick way to get the contents of a MemoryStream as an ASCII string

試著忘記壹切 提交于 2019-12-12 07:47:18
问题 I have a JSON string in a MemoryStream. I am using the following code to get it out as an ASCII string: MemoryStream memstream = new MemoryStream(); /* Write a JSON string to memstream here */ byte[] jsonBytes = new byte[memstream.Length]; memstream.Read(jsonBytes, 0, (int)memstream.Length); string jsonString = Encoding.ASCII.GetString(jsonBytes); What is a shorter/shortest way to do this? 回答1: You could use the ToArray method: using (var stream = new MemoryStream()) { /* Write a JSON string

Gunzipping Contents of a URL - Java

青春壹個敷衍的年華 提交于 2019-12-12 06:06:19
问题 So as the title suggests, I'm trying to get and gunzip a string from an HTTP request. urlConn = url.openConnection(); int len = CONTENT_LENGTH byte[] gbytes = new byte[len]; gbuffer = new GZIPInputStream(urlConn.getInputStream(), len); System.out.println(gbuffer.read(gbytes)+"/"+len); System.out.println(gbytes); result = new String(gbytes, "UTF-8"); gbuffer.close(); System.out.println(result); With some URLs, it works fine. I get output like this: 42/42 [B@96e8209 The entire 42 bytes of my

How to convert byte array to mp3 using aspx script from flash as3.0?

痞子三分冷 提交于 2019-12-12 05:38:37
问题 In Flash as3.0 recorded voice is stored in a BytesArray variable. Now need to store the recorded sound as .mp3 or .wav file in aspx script. Any can help me? How to convert byte array to audio format and save in server any concept please share. 回答1: refer a following my code. this code is skills about after recording your voice to be converted to wav or mp3 to save. converted output mp3 and wav file is is guaranteed about socket communication with the C and Java. I tested in Windows-xp(32bit)

After sending byte arrays via dataoutputstream, the received byte arrays are not equal to original byte arrays

拈花ヽ惹草 提交于 2019-12-12 04:46:46
问题 For some reasons, I need to send multiple byte arrays separately via server socket, and client socket will receive these byte arrays. After sending byte arrays, I found byte arrays received in client socket are not equal to those in server socket. If I use ObjectOutputStream and ObjectInputStream, then everything works fine, but for my need, I can't use ObjectOutputStream & ObjectInputStream, because my server need to connect more than 2 sockets. Here is Server and Client code: Server(Sender)

List of Integers into byte array

蓝咒 提交于 2019-12-12 04:37:07
问题 I have a LinkedList < Integer > with big size (3912984 or more) and I wanna copy these elements in a byte array. The integers are 0 or 1, so I don't need any change of size for array, I want just to copy elements one by one, exactly how they are. Of course, I know the simplest way is : for(int i = 0; i < list.size(); i++) array[i] = (byte)(int) list.get(i); But this method is too slow and my program doesn't end before hours ! Can you know another way (faster, something like Buffer.BlockCopy()

AS3 - AIR - From a swf path file to a ByteArray

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 04:24:47
问题 I am coding an AIR application. I've got directly a path of a swf file (because it was stored in a xml file). Do yo know if it is possible to get the ByteArray from this file ? I know that FileReference do that very well, but this class need a select event. But it isn't my case because I've allready got my path. Thanks a lot for your answers ! 回答1: In AIR, you can read/write files directly using flash.filesystem.File and flash.filesystem.FileStream. See, for example, this article. 回答2:

vb.net: Encoding byte array into string using Unicode

别说谁变了你拦得住时间么 提交于 2019-12-12 03:44:53
问题 I am reading RAW data from a source. This raw data is a sequence of Bytes. I store this sequence of Bytes into an array of Bytes that I define as following in VB.NET: Dim frame() as Byte so each element in the above array is in the range [0-255]. I want to encode each of these bytes into ASCII, UTF-8 and Unicode so I iterate over the byte array (frame) and perform below snippet code depending on the case: ASCII : For idxByte As Integer = 0 To Me.frame.Length - 1 txtRefs(idxByte).Text =

Java Parse Json Byte Array

吃可爱长大的小学妹 提交于 2019-12-12 03:16:30
问题 Im developing an Android application which are using an webservice to fetch an image that are going to be displayed in the application. I'm using JSON as my format. The whole connection process works like a charm but i need help with parsing the response from the webservice request. This is my result: [255,12,87,183,232,34,64,121,182,23] Of course this is not the real data, im just trying to explain how the data looks like when i receive it. So my question is, how do i parse this data into an