Raw integer in byte format to integer class

Hi,
This seemed like an incredibly easy problem to me at first, but for some reason I'm having a lot of trouble with it. I have an integer in byte array format, (byte[] b; the integer is in b[0],b[1],b[2] and b[3], little endian format). Can someone write a function real quickly to do this properly? I'm specifically having trouble when the byte in b[0] is a negative number, because when I add it to the integer that I have, the integer comes out negative.

I found the solution to my problem. It's as easy as taking the bytes and using 0xff&b[x] before you use them. This has the effect of converting them to unsigned bytes.

Similar Messages

  • Can I send message in byte format

    hello
    Why no one is answering me
    but still I want to know that Can I send message in byte format to inbox
    message.setContent(byte [] b, "text/plain");
    And Can I receive mail in byte format from inbox.
    String dis = new String((String)messagePart.getContent());
    plz resolve my problem

    Obviously you have a very skewed view of the world
    based on what you want to do. The most common thing
    people want to do with email is not send raw binary data.
    The most common thing people want to do is send text to be
    read by a human.
    Nonetheless, it's very easy to send binary data. Again, the
    most common case is sending text. The thing that's important
    with text is that it appear as the same text at the other end.
    That's easy. But if you have text where every CR, LF, and
    space has to appear absolutely unchanged at the other end,
    that requires a bit of extra work.
    The demo program sendfile.java that comes with JavaMail
    shows how to send a file as an attachment. That's the core
    of the program. Here's the 6 lines of code you need to add
    to that program to do what you want:
    ------- sendfile.java -------
    100c100,104
    < FileDataSource fds = new FileDataSource(filename);
    FileDataSource fds = new FileDataSource(filename) {
    public String getContentType() {
    return "application/octet-stream";
    };113a118,119
    msg.saveChanges();
    mbp2.setHeader("Content-Transfer-Encoding", "base64");Is that so hard?
    If you don't want to send the file as an attachment, but rather as the one
    and only body of the message, it's even easier. Let me know if I need
    to write that program for you as well.
    And if you already have the data in memory in a byte array, that's even
    easier still.

  • Nikon D800 raw files "unsupported image format".

    I've a problem with Nikon D800 raw files "unsupported image format".
    I've just upgrade to mountain lion with no success.
    also aperture seems the last version
    only Nikon software seems to work
    thank you
    Andrea

    Hey Andrea
    sorry for the late reply. Have been on some working holidays
    My setting is : typ>>>>  no
                           bit>>>>   14
    The only information, which is not transmitted is the adjustment level of the AF-finetuning
    Good luck and hope it works meanwhile also with your camera
    :-)) FJ

  • Raw PCM or Unsupported Format

    I am trying to import some .mp3 songs into Audition.
    When I use the shortcut import button, nothing happens.
    When I'm in multitrack view, I use
    - Insert>Audio.
    - I highlight the track I want to import
    - In the "Show File Information" box it says "Raw PCM or Unsupported Format".
    - I click open
    - A box comes up saying
    Could not open file:
    blah blah blah.mp3
    The selected file does not appear to be a supported file type.
    To attempt to open this file and interpret it as audio data, select PCMRaw Data as the File Type, enter an asterik (*) in the File Name field and click Open to display all files.
    Any ideas about how to fix this so I can import these .mp3 files into Audition?

    Cheers Steve but thats still not working.
    Tried the same process in edit mode (both shortcut and File>open) but I'm still getting the same message.
    I tried changing the file extension to .wav but still got the same message.
    I tried changing the file extension to .pcm and only got 30 seconds of white noise (it should be a 3 minute clip).
    I downloaded a crappy mp3 to wav converter off the net but that only changed the file to half a second of white noise.

  • To display an image in byte format in JSP

    hai gurus,
    I am using JSPDynpage.  My response from the websevice is retrieving image in byte format.
    so I thought to display like this in JSP
    String contentType = "image/jpeg";
                   res.setContentType(contentType);
                   //ServletOutputStream out = request.getServletResponse(true).getOutputStream();
                   res.setContentLength(data.length);
                   ServletOutputStream ostream = res.getOutputStream();
                   ostream.write(data);
                   ostream.flush();
    But it doesn't work
    It says that request object is predefined in the doContent.
    above code works fine the the abstractportalcomponent.
    let me know about this
    thanks
    venkata

    Hi, mmaybe you have more luck if you post it in the EP Content Developer or Java deloper forums.
    regards
    Marcel

  • Math and Integer classes gone???

    Hello,
    I'm using the J2ME Wireless Toolkit to build my applications. For some reason it is having problems when I try using these two classes. I get a "cannot resolve symbol" error when I try using Math.round(float) and new Integer(String). Anyone know why this is happening?
    Thanks,
    JD

    Maybe I misunderstood the original question, I thought he was asking for a function that rounded the division of a number to the closest integer. For example: 2.95 -> 3, 2.5 -> 3, 2.48 -> 2....
    I have never used fixed point math so I wanted to try out that little function of yours and I put it into my app and tested it. It seems to actually be doing integer division plus a tiny bit. Then purely on a random guess I tried replacing the 1 with a y and it was now rounding the numbers in the standard way. Here is my code and test cases:
    System.out.println(roundedRatio(180,39)+"-"+roundedRatio(180,40)+"-"+roundedRatio(180,41));
              System.out.println(roundedRatio(180,71)+"-"+roundedRatio(180,72)+"-"+roundedRatio(180,73));
              System.out.println(roundedRatio(180,119)+"-"+roundedRatio(180,120)+"-"+roundedRatio(180,121));
              System.out.println(roundedRatio1(180,39)+"-"+roundedRatio1(180,40)+"-"+roundedRatio1(180,41));
              System.out.println(roundedRatio1(180,71)+"-"+roundedRatio1(180,72)+"-"+roundedRatio1(180,73));
              System.out.println(roundedRatio1(180,119)+"-"+roundedRatio1(180,120)+"-"+roundedRatio1(180,121));
         int roundedRatio(int x, int y) {
           int fpX = x << 8; // 8 is just an arbitrary number used as fixed point precision
           int fpHalf = 1 << 7; // shift one space less and you get 0.5 with that fixed point precision
           return ((fpX + fpHalf) / y) >> 8;
          int roundedRatio1(int x, int y) {
           int fpX = x << 8; // 8 is just an arbitrary number used as fixed point precision
           int fpHalf = y << 7; // shift one space less and you get 0.5 with that fixed point precision
           return ((fpX + fpHalf) / y) >> 8;
          }float values: 180/40 = 4.5, 180/120 = 2.5 etc.
    output is:
    4-4-4
    2-2-2
    1-1-1
    5-5-4
    3-3-2
    2-2-1

  • Can you get the original bytes/format from a BufferedImage

    Applications allows users to select file and then the contents of the files are embedded into an mp3 file, but also allow images to be dragged or copy and pasted and in vertainn cases I only recieve the image as an Image DataFlavor (new DataFlavor("image/x-java-image;class=java.awt.Image");), so I have the bufferedImage but I need to convert into a stream of bytes and I don't have the bytes or even the the orginal format of the image, or are they hidden in the BufferedImage somewhere. At the moment I'm always writing the Bufferedimage as a jpeg whereas Id prefer to write the original format if supported, not least because sometimes ImageIO actually renders the file incorrectly (#4881314 , #6444933).
    thanks Paul

    Not possible. No.

  • How to display raw, not ascii, bytes from serial port?

    Hello, I have an instrument that outputs raw data, not ascii, bytes to a serial port.  How do you display raw data, not ascii, bytes from a serial port?  Since raw data bytes are not displayable, there is got to be something in labview to interpret/display the received bytes the way it is as data in HEX or Binary.  The STRING-TO-HEX and STRING-TO-BINARY functions are not applicable in this case because the bytes were not string type in the first place.  For example, if the receive byte is 0x4D, I need to display 4D in HEX or 77 in Decimal and not the ascii character "M" corresponding to 0x4D ascii code.  I am using a VISA-RD function currently to receive the data from a COM port.  VISA-RD outputs string type.  Thank for any feedback or suggestion in advance.

    BC@Baxter wrote:
    ...The STRING-TO-HEX and STRING-TO-BINARY functions are not applicable in this case because the bytes were not string type in the first place...
    Of course they are string type, just not formatted in a human readable form. So, YES, these functions are not appropriate.
    BC@Baxter wrote:
    For example, if the receive byte is 0x4D, I need to display 4D in HEX or 77 in Decimal and not the ascii character "M" corresponding to 0x4D ascii code. 
    Dennis is right, but there is no "decimal" display for strings, so the second requirement needs a tiny little bit more code.
    If you have a single byte string, you can typecast it into a U8 number and set the display format as decimal, hex, octal, or binary as desired. In decimal, it would display the number 77. Since it is now a numeric, you can even do math with it.
    In general, the string has multiple bytes, and you would typecast it into an array of U8 numbers (Since this is an often used function, there is also a "string to byte array" which does the same thing).
    Typecasting is the secret. You can e.g. easily typecast 2 bytes into a U16, 4 bytes into a I32, 8 bytes into a DBL,  etc. For more detailed requirements, there is also the "unflatten from string". Check the online help for details. Good luck!
    LabVIEW Champion . Do more with less code and in less time .

  • Image from raw UYVY(YUV_422) bytes

    Hey everyone,
    First off, I'm a JMF & imaging noob, so take it easy on me lol. I've been searching through the forum, and this is as far as I've been able to go.
    Here's the problem, we have a Sony DFW-X710 camera that came with IC Imaging Control software & SDK. The JMF Registry doesn't pick up the device. So we've used some lovely JNI to get the raw bytes back to Java. As far as I can tell, the image information is coming back thru to Java just fine. When I try to create an image file thru BufferToImage.createImage(..), it displays as all black. The camera settings are:
    1024x768
    15 FPS
    UYVY
    The code I'm using minus the standard GUI stuff:
    //raw bytes from the JNI
    byte[] array = triggerAndReturnImage();
    Buffer buf = new Buffer();
    YUVFormat yuv = new YUVFormat(new java.awt.Dimension(1024,768) ,
    Format.NOT_SPECIFIED, Format.byteArray,
    15f,YUVFormat.YUV_422,2,4,1,0,2);
    buf.setFormat(yuv);
    buf.setData(array);
    BufferToImage buf2Image = new BufferToImage(yuv);
    Image newImage = buf2Image.createImage(buf);
    System.out.println("New image is: " + newImage);
    The image seems to create fine, but like I said, a pure black image.
    The output I get from the println is as follows:
    New image is: BufferedImage@1ea0252: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 1024 height = 768 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
    1024,768
    Any insight anyone can give would be much appreciated.
    -Jeff
    FYI: I've ensured/tried the following:
    *the lense cap is off
    *the camera takes pictures fine
    *I can save them from the C++ side (but I don't want to do that because that will take too long to save and reopen in Java for the app we're working on),
    *I've reversed the byte order (because the SDK says the images are stored bottom up)
    *I've tried without reversing the bytes
    *The CINEPAK VideoFormat but for some reason won't return an image                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    It is supposed to work, you can create a Buffered Image of given height, width and imagetype and you can set single Pixels with setRGB. I assume this will be quite slow, but it will work.
    If your data is in the form of int[]rgb (rgb each 8 bit + 8 fill bits) than you can use a setRGB variant, which copies a complete area (read array) into the buffered image, which is presumeably faster especially if you choose int[]rgb as image type for your BufferedImage as well.
    Regards
    SH

  • Saving processed files in original raw (or DNG?) format

    Hello. I'm new to Lightroom, so although I've spent a day or so ploughing through the tutorials, please accept my apologies if my question seems dumb.
    However I can't see an answer to my problem so far.
    It is this: after importing my raw files (CR2) into Lightroom and processing them etc to get them to a result I'm happy with, I'd now like to be able to keep the new, processed version of my images somewhere in Lightroom in the original raw format so that I can quickly access those processed images again in the future and then export in  appropriate formats as I choose, which might be screen jpegs or prints or whatever – different from my first export.
    In other words, I know I can 'save' (export) files to a folder as jpegs etc, but if I subsequently decide to export those same files in a different format (e.g prints), I don't want to have to go back to the original raw files and start the processing all over again to arrive at what I'd already been happy with, in order to re-export.
    I suspect I'm missing something really basic here, but it's so basic I can't work out what it is!
    I suppose another way of reframing the question might be: is there a way I can save and store my processed raw images in Lightroom so that I can access them easily, and not have to re-process them unless I want to?
    I haven't yet got my head around DNG files. Is this part of the solution perhaps?
    Lightroom is incredibly fantastic, but now that I've managed to get my images to where I want them, I don't want to re-visit the processing on them un-necessarily, which is what I seem to be doing at the moment...
    I have Lightroom 5.4 on a Macbook Air running Mavericks OSX 10.9.2 if it makes any difference.
    Thank you, I would be very grateful for your advice.

    While the advice to read Victoria bampton's Quick Start Guide is excellent, I'd like to provide a little shorter piece of philosphy that might help
    Lightroom works differenlty than any other software you may have used in the past. You would be wise to eliminate from your brain your ideas about how to manage files and edits that might have been present in your mind from your use of other photo editing software. You would be wise to start using Lightroom with a clean slate in your mind about how things work. Your statements above show clearly that you are thinking that Lightroom works the same as other photo managing/editing software, and this will lead you/already has lead you in the wrong direction, and in harmful directions.
    So wipe the slate clean. Prepare to learn how to manage files and manage edits from a clean slate.
    Things that are different about Lightroom
    Lightroom is completely non-destructive editing. This means that the pixels in your original photos are NEVER (that's NEVER, a very strong word, chosen intentionally to mean, well it means NEVER) changed by Lightroom. This implies that you do NOT need to make a copy of a photo before you start editing it. Making a copy of a photo before you start editing it is a complete waste of time and disk space. (Also see side comment below)
    Edits are not stored by saving a copy of the edited photo on your hard disk, as Photoshop or Photoshop Elements would do. Edits are not, by default, stored in the photo file itself. Edits are stored in the Lightroom catalog, which is a database file. The edits are essentially stored as numbers (example: Exposure +0.5, contrast +20, Highlights –15) in the catalog. You cannot turn this method of saving edits in the catalog off. As a result, if you close Lightroom after you perform some edits, and then open Lightroom again at some later time, your edits will be in the catalog, and displayed for you automatically, without you taking any specific "save" action or without you taking any specific action to tell Lightroom to display the edits.
    However, some people make the critical mistake of removing the photos from Lightroom after the edits are completed ... this also removes the edits from Lightroom and (in Lightroom's default mode of operation) the edits are now lost forever. Even if you use an option in Lightroom to store the edits with the file, this mode of operation requires you to do more work and you recieve less benefits from Lightroom, than simply leaving the photos in Lightroom. Removing photos from Lightroom after the edits are completed is highly unrecommended.
    Photos are never stored in Lightroom. Photos are always stored on your hard disk. They are stored wherever you put them, or where you instruct Lightroom to put them on your hard disk during Import. Lightroom maintains a link in its database to the file's location on disk. As a result, if you move or rename or delete your photos (or the folders that contain them) outside of Lightroom, then Lightroom cannot find the photos and you can no longer work with them in Lightroom. There are ways to fix this, but the best solution IN MY OPINION, is to no longer manage/organize your photos via operating system/folders/file names and to no longer manage/organize your photos by moving them from here to there after importing them; rather you should manage/organize your photos using Lightroom tools such as keywords and other metadata and then you not only have more powerful tools for managing/organizing than you have in your operating system, but the issue regarding Lightroom not being able to find your photos goes away
    Side comment: in item 1 I said you don't have to make a copy before you edit the photos. However you do need to make backups (identical copies) of your original photos and catalog file on a different hard disk. This is to protect against the future situation where your hard disk will fail, resulting in the loss of your photos, and to protect against accidental erasure of your original photos. It is not to protect against Lightroom changing the pixels of your original photos, which as I said, Lightroom does not do.

  • How do I  Send HTML formatted email  using  class in  javax.mail pkg

    How do I Send HTML formatted email using javax.mail pkg class ?i mean is thr any class available in this package to do this ?

    Please see
    http://javaalmanac.com/egs/javax.mail/SendApp.html
    for Quintessential Program to Send E-Mail.
    Then substitute line
    msg.setText(content);
    /with this one
    msg.setContent( content , "text/html");
    it should do in simplest form.

  • Aperture 3 and DNGs from LX5 raw files: unsupported image format

    My LX5 arrived, and I tried converting a raw file to DNG with Adobe DNG Converter 6.2.0.21 beta and importing it into Aperture. No luck: Aperture says it's an unsupported image format. I tried setting the compatibility as far back as possible in the preferences, and still no luck. Any idea why this doesn't work? I used Adobe DNG Converter multiple times to work with raw files from unsupported cameras, so it's a real surprise to get the unsupported image file message.
    —Andreas

    Unfortunately, this is more about Apple dragging its feet than a cutting edge issue. I got an LX3 and upgraded to Aperture 3 in February of this year. RW2s straight out of the camera always imported just fine. However, I've never been able to get a DNG generated from an RW2 with Adobe DNG converter to work. Interestingly, DNGs from another file format I use (PEF) work fine in Aperture.
    I submitted a issue report to Apple about the RW2 to DNG problem back in March, and like so many other suggestions to them, it seems to have vanished into the ether.

  • Does Aperture support RAW 3F (*.fff) file format?

    I am scanning all of my film with a Hasselblad FlexTight F1 scanner. I saved the files in their RAW format called 3F (*.fff). I am completely schocked that Aperture doesn't recognize the file format. After all, isn't Apple selling Aperture as "Professional Applications"? Hmm, what is more professional than scanning film with a $15,000 FlextTight scanner?
    What are they thinking, or what am I missing? I just don't get it.

    Well, if you look closely at the technical specifications (http://www.apple.com/aperture/specs/raw.html), you'll see that Aperture is meant for digital images taken with a digital camera and not for scans, sorry.
    Wide Support for RAW Formats from Leading Cameras
    Aperture 3 supports the RAW formats from more than 150 digital cameras and camera backs. Aperture also lets you work with most DNG files.1 Shoot JPEG? Using Aperture, you can import JPEG images from virtually all digital cameras.
    As a work-around, try another lossless format for your scans. Are your scans very large? Then you may possibly run into another problem because of the file size. I am having frequently problems with Aperture being unresponsive, if the image file size of my scans is close to 1 GB.

  • 10.5.2; Canon 1DsM3 Raw Files = "Unsupported Image Format" in Aperture

    Just did the update and pointed Aperture to a folder of Canon 1Ds Mark III raw files (standard raw files, no sRaw or anything like that). Thumbnail previews are grey and Viewer says, "Unsupported Image Format".
    Tried rebooting and verifying/fixing permissions. No help. No thumbnails, no images in Aperture.
    Canon 1Ds Mark III raw files do show fine in the finder and in Quick Look.
    Message was edited by: Jon Roemer

    I have the same exact issue.
    I do get the same error with 1Ds MIII raws.
    Also the G9 raws are not working.
    Finally after 3 months it's still not working
    I could imagine that there is the need to edit some property file (like I have read before in the forum somewere) to add the new cameras to the list of supported cameras.
    Are the D3, D300 raws working?

  • Canon C500 Raw and RMF file format

    Does anyone know if Adobe has plans to include native support for the Canon 4K Raw file format (.RMF) specifically for speedgrade and After Effects? I am looking at work flows for an upcoming project that will most likely be shot on the C500 in 4k recorded raw onto the Gemeni 4:4:4 external recorder but my adobe suite has no way to color grade the dailies or even link up the online and offline edit without support for the raw files. If there is something forth coming what is the time frame if not is there a 3rd party solution?
    Thanks,

    >Does anyone know
    No employee or Beta tester is allowed to comment on Adobe's plans
    Go to https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform to tell Adobe what you need

Maybe you are looking for

  • BPEL Scheduling in SOA Suite 11g

    Hi, I am new to Oracle SOA. I have come across of multiple ways of scheduling in BPEL (Using Servelts with Quartz, DBMS_JOB, Enterprise Scheduler, Wiat activity etc). Can any one suggest best approach to handle various scenarios in scheduling. What i

  • Java NIO Vs Normal IO

    hi ppl...i want to know when v should prefer nio over normal io. I read somewhere that only if you have to deal with a lot of connections simultaneously you should consider using NIO. as an example it said that a web spider which needs to process a f

  • Product category not visible in search help

    Hello, We have performed changes to product categories in Dev system and moved it to Q. I can see all the cateogories correctly in COMM_HIERARCHY, but when I try to add them in the org structure to users, I can't find them. Any idea, why this could h

  • Flash MX - invisible buttons

    I've created my first nav menu using Flash - hooray! The nav menu items are invisible buttons with movies beneath them. It all works fine in terms of navigating the site. However, I would like to make it accessible (i.e. have shortcut / access key as

  • I'm having trouble syncing with icloud.  Please help.

    I'm having trouble syncing with icloud. I'm trying to sync my iphone & my new ipad.  HELP