Search Results

Search found 3443 results on 138 pages for 'byte'.

Page 7/138 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Representing a 16 byte variable

    - by Bobby
    I have to represent a 16 byte field as part of a data structure: struct Data_Entry { uint8 CUI_Type; uint8 CUI_Size; uint16 Src_Refresh_Period; uint16 Src_Buffer_Size; uint16 Src_CUI_Offset; uint32 Src_BCW_Address; uint32 Src_Previous_Timestamp; /* The field below should be a 16 byte field */ uint32 Data; }; How would I represent the "Data" field as a 16 byte field instead of the 4 byte field it currently is? Thanks, Bobby

    Read the article

  • how to convert bitmap into byte array in android

    - by satyamurthy
    hi all i am new in android i am implementing image retrieve in sdcard in image convert into bitmap and in bitmap convert in to byte array please forward some solution of this code public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageView image = (ImageView) findViewById(R.id.picview); EditText value=(EditText)findViewById(R.id.EditText01); FileInputStream in; BufferedInputStream buf; try { in = new FileInputStream("/sdcard/pictures/1.jpg"); buf = new BufferedInputStream(in,1070); System.out.println("1.................."+buf); byte[] bMapArray= new byte[buf.available()]; buf.read(bMapArray); Bitmap bMap = BitmapFactory.decodeByteArray(bMapArray, 0, bMapArray.length); for (int i = 0; i < bMapArray.length; i++) { System.out.print("bytearray"+bMapArray[i]); } image.setImageBitmap(bMap); value.setText(bMapArray.toString()); if (in != null) { in.close(); } if (buf != null) { buf.close(); } } catch (Exception e) { Log.e("Error reading file", e.toString()); } } } solution is 04-12 16:41:16.168: INFO/System.out(728): 4......................[B@435a2908 this is the result for byte array not display total byte array this array size is 1034 please forward some solution

    Read the article

  • PHP Convert C# Hex Blob Hexadecimal String back to Byte Array prior to decryption

    - by PolishHurricane
    I have a piece of data that I am receiving in hexadecimal string format, example: "65E0C8DEB69EA114567954". It was made this way in C# by converting a byte array to a hexadecimal string. However, I am using PHP to read this string and need to temporarily convert this back to the byte array. If it matters, I will be decrypting this byte array, then reconverting it to unencrypted hexadecimal and or plaintext, but I will figure that out later. So the question is, how do I convert a string like the above back to an encoded byte array/ blob in PHP? Thanks!

    Read the article

  • Misalignement in the output Bitmap created from a byte array

    - by Daniel
    I am trying to understand why I have troubles creating a Bitmap from a byte array. I post this after a careful scrutiny of the existing posts about Bitmap creation from byte arrays, like the followings: Creating a bitmap from a byte[], Working with Image and Bitmap in c#?, C#: Bitmap Creation using bytes array My code is aimed to execute a filter on a digital image 8bppIndexed writing the pixel value on a byte [] buffer to be converted again (after some processing to manage gray levels) in a 8BppIndexed Bitmap My input image is a trivial image created by means of specific perl code: https://www.box.com/shared/zqt46c4pcvmxhc92i7ct Of course, after executing the filter the output image has lost the first and last rows and the first and last columns, due to the way the filter manage borders, so from the original 256 x 256 image i get a 254 x 254 image. Just to stay focused on the issue I have commented the code responsible for executing the filter so that the operation really performed is an obvious: ComputedPixel = InputImage.GetPixel(myColumn, myRow).R; I know, i should use lock and unlock but I prefer one headache one by one. Anyway this code should be a sort of identity transform, and at last i use: private unsafe void FillOutputImage() { OutputImage = new Bitmap (OutputImageCols, OutputImageRows , PixelFormat .Format8bppIndexed); ColorPalette ncp = OutputImage.Palette; for (int i = 0; i < 256; i++) ncp.Entries[i] = Color .FromArgb(255, i, i, i); OutputImage.Palette = ncp; Rectangle area = new Rectangle(0, 0, OutputImageCols, OutputImageRows); var data = OutputImage.LockBits(area, ImageLockMode.WriteOnly, OutputImage.PixelFormat); Marshal .Copy (byteBuffer, 0, data.Scan0, byteBuffer.Length); OutputImage.UnlockBits(data); } The output image I get is the following: https://www.box.com/shared/p6tubyi6dsf7cyregg9e It is quite clear that I am losing a pixel per row, but i cannot understand why: I have carefully controlled all the parameters: OutputImageCols, OutputImageRows and the byte [] byteBuffer length and content even writing known values as way to test. The code is nearly identical to other code posted in stackOverflow and elsewhere. Someone maybe could help to identify where the problem is? Thanks a lot

    Read the article

  • Passing an ActionScript JPG Byte Array to Javscript (and eventually to PHP)

    - by Gus
    Our web application has a feature which uses Flash (AS3) to take photos using the user's web cam, then passes the resulting byte array to PHP where it is reconstructed and saved on the server. However, we need to be able to take this web application offline, and we have chosen Gears to do so. The user takes the app offline, performs his tasks, then when he's reconnected to the server, we "sync" the data back with our central database. We don't have PHP to interact with Flash anymore, but we still need to allow users to take and save photos. We don't know how to save a JPG that Flash creates in a local database. Our hope was that we could save the byte array, a serialized string, or somehow actually persist the object itself, then pass it back to either PHP or Flash (and then PHP) to recreate the JPG. We have tried: - passing the byte array to Javascript instead of PHP, but javascript doesn't seem to be able to do anything with it (the object seems to be stripped of its methods) - stringifying the byte array in Flash, and then passing it to Javascript, but we always get the same string: ÿØÿà Now we are thinking of serializing the string in Flash, passing it to Javascript, then on the return route, passing that string back to Flash which will then pass it to PHP to be reconstructed as a JPG. (whew). Since no one on our team has extensive Flash background, we're a bit lost. Is serialization the way to go? Is there a more realistic way to do this? Does anyone have any experience with this sort of thing? Perhaps we can build a javascript class that is the same as the byte array class in AS?

    Read the article

  • Is there a simpler way to convert a byte array to a 2-byte-size hexadecimal string?

    - by Tom Brito
    Is there a simpler way of implement this? Or a implemented method in JDK or other lib? /** * Convert a byte array to 2-byte-size hexadecimal String. */ public static String to2DigitsHex(byte[] bytes) { String hexData = ""; for (int i = 0; i < bytes.length; i++) { int intV = bytes[i] & 0xFF; // positive int String hexV = Integer.toHexString(intV); if (hexV.length() < 2) { hexV = "0" + hexV; } hexData += hexV; } return hexData; } public static void main(String[] args) { System.out.println(to2DigitsHex(new byte[] {8, 10, 12})); } the output is: "08 0A 0C" (without the spaces)

    Read the article

  • How to retreive SID's byte array

    - by rursw1
    Hello experts, How can I convert a PSID type into a byte array that contains the byte value of the SID? Something like: PSID pSid; byte sidBytes[68];//Max. length of SID in bytes is 68 if(GetAccountSid( NULL, // default lookup logic AccountName,// account to obtain SID &pSid // buffer to allocate to contain resultant SID ) { ConvertPSIDToByteArray(pSid, sidBytes); } --how should I write the function ConvertPSIDToByteArray? Thank you!

    Read the article

  • Byte from string/int in C++

    - by Tim van Elsloo
    Hi, I'm a beginning user in C++ and I want to know how to do this: How can I 'create' a byte from a string/int. So for example I've: string some_byte = "202"; When I would save that byte to a file, I want that the file is 1 byte instead of 3 bytes. How is that possible? Thanks in advance, Tim

    Read the article

  • BuiltIn Function to Convert from Hex String to Byte

    - by Ngu Soon Hui
    This question is similar to the one here. One can easily convert from hex string to byte via the following formula: public static byte[] HexStringToBytes(string hex) { byte[] data = new byte[hex.Length /2]; int j = 0; for (int i = 0; i < hex.Length; i+=2) { data[ j ] = Convert.ToByte(hex.Substring(i, 2), 16); ++j; } return data; } But is there a built-in function ( inside .net framework) for this?

    Read the article

  • How do I convert byte to string?

    - by HardCoder1986
    Hello! Is there any fast way to convert given byte (like, by number - 65) to it's text hex representation? Basically, I want to convert array of bytes into (I am hardcoding resources) their code-representation like BYTE data[] = {0x00, 0x0A, 0x00, 0x01, ... } How do I automate this Given byte -> "0x0A" string conversion?

    Read the article

  • Continue NSURLConnection/NSURLRequest from a given Byte

    - by Sj
    I am working with a web service right now that requires me to upload video binaries straight to their web form via the iPhone SDK. Simple enough. The part that is getting me though is when the connection is interrupted, they want me to be able to continue the upload from a given byte. So here is what I have: the original data & the last byte uploaded What I need to know: how can I continue the data from that byte? I seems like it would be something similar to truncating NSData by the byte but I do not know how to do that for an NSURLConnection/NSURLRequest. Thank you!

    Read the article

  • pointer is always byte aligned

    - by kumar
    Hi, I read something like pointer must be byte-aligned. My understanding in a typical 32bit architecture... all pointers are byte aligned...No ? Please confirm. can there be a pointer which is not byte-aligned ?

    Read the article

  • C# Image.Clone to byte[] causes EDIT.COM to open on Windows XP

    - by JayDial
    It appears that cloning a Image and converting it to a byte array is causing EDIT.COM to open up on Windows XP machines. This does not happen on a Windows 7 machine. The application is a C# .NET 2.0 application. Does anyone have any idea why this may be happening? Here is my Image conversion code: public static byte[] CovertImageToByteArray(Image imageToConvert) { imageToConvert.Clone() as Image; if(clone == null) return null; imageToConvert.Dispose(); byte[] imageByteArray; using (MemoryStream ms = new MemoryStream()) { clone.Save(ms, clone.RawFormat); imageByteArray = ms.ToArray(); } return imageByteArray; } public static Image ConvertByteArrayToImage(byte[] imageByteArray, ImageFormat formatOfImage) { Image image; using ( MemoryStream ms = new MemoryStream(imageByteArray, 0, imageByteArray.Length)) { ms.Write(imageByteArray, 0, imageByteArray.Length); image = Image.FromStream(ms, true); } return image; } Thanks Justin

    Read the article

  • Convert jpg Byte[] to Texture2D

    - by Damien Sawyer
    I need to import jpeg images into a WP7/XNA app with associated metadata. The program which manages these images exports to an XML file with an encoded byte[] of the jpg files. I've written a custom importer/processor which successfully imports the reserialized objects into my XNA project. My question is, given the byte[] of the jpg, what is the best way to convert it back to Texture2D. // 'Standard' method for importing image Texture2D texture1 = Content.Load<Texture2D>("artwork"); // Uses the standard Content processor "Texture - XNA Framework" to import an image. // 'Custom' method var myCustomObject = Content.Load<CompiledBNBImage>("gamedata"); // Uses my custom content Processor to return POCO "CompiledBNBImage" byte[] myJPEGByteArray = myCustomObject.Image; // byte[] of jpeg Texture2D texture2 = ???? // What is the best way to convert myJPEGByteArray to a Texture2D? Thanks very much for your help. :-) DS

    Read the article

  • Copying a byte buffer with JNI

    - by Daniel
    I've found plenty of tutorials / questions on Stackoverflow that deal with copying char arrays from C/JNI side into something like a byte[] in Java, but not the other way around. I am using a native C library which expects a byte array. I simply want to get data from a byte[] in java, into preferably an unsigned char[] in C. Long story short: What is the best way of copying data from a jBytearray in JNI? Is there any way to detect it's size?

    Read the article

  • How do I initialize a fixed byte array?

    - by Jurily
    I have the following struct: [StructLayout(LayoutKind.Sequential, Pack = 1)] struct cAuthLogonChallenge { byte cmd; byte error; fixed byte name[4]; public cAuthLogonChallenge() { cmd = 0x04; error = 0x00; name = ??? } } name is supposed to be a null-terminated ASCII string, and Visual Studio is rejecting all my ideas to interact with it. How do I set it?

    Read the article

  • What type is System.Byte[*]

    - by Jimbo
    I'm being passed an object that returns "System.Byte[*]" when converted to string. This apparently isn't a standard one dimensional array of Byte objects ("System.Byte[]"), so what is it?

    Read the article

  • How to extract byte-array from one xml and store it in another in Java

    - by grobartn
    So I am using DocumentBuilderFactory and DocumentBuilder to parse an xml. So it is DOM parser. But what I am trying to do is extract byte-array data (its an image encoded in base64) Store it in one object and later in code write it out to another xml encoded in base64. What is the best way to store this in btw. Store it as string? or as ByteArray? How can I extract byte array data in best way and write it out. I am not experienced with this so wanted to get opinion from the group. UPDATE: I am given XML I do not have control of incoming XML that comes in binary64 encoded < byte-array > ... base64 encoded image ... < /byte-array > Using parser I have I need to store this node and question is should that be byte or string and then writing it out to another node in new xml. again in base64 encoding. thanks

    Read the article

  • Convert a image to a monochrome byte array

    - by Scott Chamberlain
    I am writing a library to interface C# with the EPL2 printer language. One feature I would like to try to implement is printing images, the specification doc says p1 = Width of graphic Width of graphic in bytes. Eight (8) dots = one (1) byte of data. p2 = Length of graphic Length of graphic in dots (or print lines) Data = Raw binary data without graphic file formatting. Data must be in bytes. Multiply the width in bytes (p1) by the number of print lines (p2) for the total amount of graphic data. The printer automatically calculates the exact size of the data block based upon this formula. I plan on my source image being a 1 bit per pixel bmp file, already scaled to size. I just don't know how to get it from that format in to a byte[] for me to send off to the printer. I tried ImageConverter.ConvertTo(Object, Type) it succeeds but the array it outputs is not the correct size and the documentation is very lacking on how the output is formatted. My current test code. Bitmap i = (Bitmap)Bitmap.FromFile("test.bmp"); ImageConverter ic = new ImageConverter(); byte[] b = (byte[])ic.ConvertTo(i, typeof(byte[])); Any help is greatly appreciated even if it is in a totally different direction.

    Read the article

  • convert a class to byte array + C#

    - by Newbie
    How can I convert a Class to byte array in C#. This is a managed one so the following code is failing int objsize = System.Runtime.InteropServices.Marshal.SizeOf(objTimeSeries3D); byte[] arr = new byte[objsize]; IntPtr buff = System.Runtime.InteropServices.Marshal.AllocHGlobal(objsize); System.Runtime.InteropServices.Marshal.StructureToPtr(objTimeSeries3D, buff, true); System.Runtime.InteropServices.Marshal.Copy(buff, arr, 0, objsize); System.Runtime.InteropServices.Marshal.FreeHGlobal(buff); Thanks

    Read the article

  • Get Python 2.7's 'json' to not throw an exception when it encounters random byte strings

    - by Chris Dutrow
    Trying to encode a a dict object into json using Python 2.7's json (ie: import json). The object has some byte strings in it that are "pickled" data using cPickle, so for json's purposes, they are basically random byte strings. I was using django.utils's simplejson and this worked fine. But I recently switched to Python 2.7 on google app engine and they don't seem to have simplejson available anymore. Now that I am using json, it throws an exception when it encounters bytes that aren't part of UTF-8. The error that I'm getting is: UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 0: invalid start byte It would be nice if it printed out a string of the character codes like the debugging might do, ie: \u0002]q\u0000U\u001201. But I really don't much care how it handles this data just as long as it doesn't throw an exception and continues serializing the information that it does recognize. How can I make this happen? Thanks!

    Read the article

  • How to store byte[] from Android Camera onPictureTaken method within application for later use

    - by Kiel Wood
    I am writing a larger Android application and I use the camera within the app. All I want to do with the camera is have the user take a picture, then start a new activity to show that image and allow the user to decide if they want to keep the image or not. I am having the hardest time figuring out how to simply store the byte[] data from the onPictureTaken method so that I can display it to the user in the next activity. I have tried many different routes and none of them have worked. The last thing I tried was creating a globalsettings class that extends the Application class and creating a byte[] field within it to store the byte[] from the camera so that I could use it within another activity, but my global variable is still not getting set. My CameraActivity code is shown below: public class CameraActivity extends Activity { CameraPreview Preview; Intent intent; byte[] image; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.cameralayout); Preview = new CameraPreview(this); ((FrameLayout)findViewById(R.id.uxfmlayPreview)).addView(Preview); intent = new Intent(this, PostCaptureActivity.class); } public void uxbtnCaptureSnap_Click(View v) { Preview.DeviceCamera.setPreviewCallback(null); Preview.DeviceCamera.takePicture(shutterCallback, rawCallback, jpegCallback); startActivity(intent); finish(); } public void uxbtnCaptureExit_Click(View v) { Intent i = new Intent(this, ExploreMenuActivity.class); setResult(RESULT_OK); startActivity(i); finish(); } ShutterCallback shutterCallback = new ShutterCallback() { public void onShutter() {} }; PictureCallback rawCallback = new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) {} }; PictureCallback jpegCallback = new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { ((GlobalSettings)getApplication()).setGlobalImage(data); camera.release(); camera = null; } }; } Here is my code from my PostCaptureActivity onCreate() method where I attempt to convert and set the image as the source for an imageview: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.postcapturelayout); SnapShot = ((ImageView)findViewById(R.id.uximgSnapshot)); if(((GlobalSettings)this.getApplication()).getGlobalImage() != null) { Bitmap b = BitmapFactory.decodeByteArray(((GlobalSettings)this.getApplication()).getGlobalImage(), 0, ((GlobalSettings)this.getApplication()).getGlobalImage().length); SnapShot.setImageBitmap(b); } else { Toast.makeText(this, "Oops! Picture cannot be saved", Toast.LENGTH_SHORT).show(); } }

    Read the article

  • How to cast/convert form Object in an byte[] array

    - by maddash
    I've got a maybe simple problem, but at the moment I am not able to solve it. I have an Object and I need to convert it into a byte[]. public byte[] GetMapiPropertyBytes(string propIdentifier) { return (byte[])this.GetMapiProperty(propIdentifier); //InvalidCastException } Exception: Unable to cast COM object of type 'System.__ComObject' to class type 'System.Byte[]'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface. So far so good - I've tried to serialize it, but I got another exception - NOT serializable Could someone help me? I need a method to convert it...

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >