How to convert hexString to jpeg ?

hi everyone,
I want to convert hexstring to an image(jpeg format ). First I converted hex to byte and then byte to BufferedImage but it dosent work.

public boolean convertHexToByte(String img){
byte[] b=new byte[img.length()/2];
int i;
try{
  for(i=0;i<=img.length()/2 -1;i++)  {
      b=(byte)Integer.parseInt(img.substring(2*i, 2*i+2), 16);
PoliceImage=convertByteToImage(b);
return true;
catch(Exception ex){
return false;
public BufferedImage convertByteToImage(byte[] b ) throws IOException{
try {
int w = 2;
int h = 2;
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
int[] nBits = {8};
ColorModel cm = new ComponentColorModel(cs, nBits, false, true, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
SampleModel sm = cm.createCompatibleSampleModel(w, h);
DataBufferByte db = new DataBufferByte(b, w * h);
WritableRaster raster = Raster.createWritableRaster(sm, db, null);
BufferedImage bm = new BufferedImage(cm, raster, false, null);
return bm;
} catch (Exception ex) {
Logger.getLogger(PoliceCard.class.getName()).log(Level.SEVERE, null, ex);

Similar Messages

  • How to convert HexString to Srting?

    Hi everybody....
    I encountered a problem... I need to convert HexString to normal String. I have no idea how to do it. Can anybody help me please....

    not exactly sure what you mean. A HexString is a String. What value are you looking for?

  • How to convert .pngs to jpeg....

    Ok i have about 70 imgs i brought into the library in Flash CS5. Now the SWF is to big bc there all .png files, i tried to go into properties and change there .png to .jpeg but its a very looooong process, is there any way to highlight them all and either change them but updating the .pngs to .jpeg files ?
    Thanks

    Hi bob, This is a feature that's available in PShop and i have used that many times, i want to take the images in Flash and convert them to jpeg, such as if i go to an image in the library and right click (Google what right clicking is you MAC users...ahem ) and i have options to update or hit properties. I want to update and take that .png file that's in the library and update with an.jpg file (one.png > one.jpeg) but now that im going into it more im thinking i have to redo it because what im asking defines some rules..

  • How to convert pdf to jpeg

    How do I convert a pdf to a jpeg

    Hi Wildgame,
    In order to convert PDF to JPG, you need to purchase Adobe Acrobat XI. You can purchase Adobe Acrobat and using that you will be able to convert PDF to JPG. For more information, please refer to the link: http://www.adobe.com/products/acrobat.html
    Also, you can check the functionality of Adobe Acrobat by downloading and installing the trial version which is fully functional and valid for 30 days. In order to download trial version, please refer to the link: https://www.acrobat.com/free-trial-download.html?trackingid=KLBBQ

  • How to convert raw to jpeg in aperture???

    I am new to this and cannot figure out how to save it in Jpeg

    When you export an image, you select a file format such as JPG (and much else besides). Until you export raw images, you should keep them raw, as that allows you to retain much more data, and gives you much more latitude in changes you can make to the image.

  • How to convert hexString to Long?

    do they have some parser for this ?
    the only thin i saw is toHexString wich is in Long .
    what about hexString to Long ?
    or : OctalString to long ?
    or : BinaryString to Long ?

    Long.parseLong(String s, int radix) with radix=16, 8, or 2.

  • How to convert RAW files to JPEG?

    I have a bunch of raw files and I am not sure how to convert them to JPEG.  I sure would appreciate some help with this.  Thank you

    As you are posting on the Canon forum, I will assume you are using a Canon camera.  Your camera came with the software you need.  It's called Digital Photo Professional.  It will also have the user manual for the software.

  • I have a new Sony alpha 77ii.  My PS version is 5.0.  When I open the files in Bridge, they are .ARW files.  How do I convert them to JPEG's so I can view and edit them?

    I have a new  Sony alpha 77ii.  My PS version is 5.0.  When I open the files with Bridge they are .ARW files.  How do I convert them to JPEG's or something I can view and edit?

    You can use Adobe's free DNG converter to convert proprietary raws to the universal DNG raw format. Here are the links:
    Adobe - Adobe Camera Raw and DNG Converter : For Windows : Adobe DNG Converter 9.0
    Adobe - Adobe Camera Raw and DNG Converter : For Macintosh : Adobe DNG Converter 9.0
    Converting to JPEG will be an extra step afterwards.
    Benjamin

  • I have LR from 2 through 4.4,  I am simply trying to adjust CR2s, and convert the them JPEG.  LR says my Perfectly Clear is expired but my update is up to date and all paid for.  What is Perfectly Clear and how do i get this puppy to be part of the team?

    i have LR from 2 through 4.4,  I am simply trying to adjust CR2s, and convert the them JPEG.  LR says my Perfectly Clear is expired but my update is up to date and all paid for.  What is Perfectly Clear and how do i get this puppy to be part of the team?

    Perfectly Clear is a 3rd party commercial plugin for Lightroom.
    http://www.athentech.com/products/plugins/
    Have you ever installed it as a trial in the past?

  • How to convert jpeg files into word

    How to convert jpeg files into Word

    Hi Eugene,
    I don't think you can convert an image to a Word document, but you could place the JPEG into a Word document using the Insert > Object command in Word.
    For other questions relating to Word, you will probably have more luck getting an answer if you post on the Microsoft forums (we can help if you're using Acrobat, or another Adobe product, but you'll find the Word experts on the Microsoft forums.)
    Best,
    Sara

  • How do I convert a scanned JPEG file to a Word document with Acrobat pro X1?

    How do I convert a scanned JPEG document into a Word document. I have Adobe Acrobat Pro Xl.

    Was it a scan of a page with only text? Text and pictures? Or just a picture?

  • How to convert JPEG/RTP Buffer to non-RTP (RAW) format ?

    Hi everybody !
    Could somebody tell me how to convert JPEG/RTP Buffer to non-RTP (RAW) format ? Thanks !

    Hi
       The way is you have to split the data several and concatenate after that.
    Regards,
    kumar

  • How do i convert raw to jpeg in aperture

    How do I convert raw to jpeg in Aperture 3 ?

    I find all this rather strange! I often convert RAW to Jpeg if I want to keep an image for reference but it doesn't merit or require the 8 to 10MB of the RAW file (on my computer, my external drive, or anywhere else). For example, I take photos of artefacts in museums, and I also photograph the labels/legends beside them, for reference. I can keep those solely as quite small Jpegs since I'm never going to want to print them.
    (No, I don't want to switch settings on the camera while I do this - I'll only forget to switch back, and then have loads of low-res Jpegs that were meant to be glorious RAW).
    In other software I've used, there's a batch convert that makes this very simple. Seems that in Aperture I'm obliged to export and then re-import. Not a big deal, but a slight pain in the arse all the same, and a little odd.
    Anyway, thanks to the above posts, I now know how to do the export-import malarkey. I couldn't find it in the manual.
    cheers,
    Helen

  • How to convert jpeg to pdf for free?

    How to convert jpeg file to pdf file for free?

    You can also Download Acrobat XI Trial from the below link and Install it and use it for 30 days ....
    http://www.adobe.com/cfusion/tdrc/index.cfm?product=acrobat_pro&loc=us

  • HOW TO CONVERT RAW FILES TO JPEG RGB 8 BIT in iphoto

    Can someone please tell me how to convert RAW files to jpeg RGB 8 bit in iphoto on an iMac?

    How are you trying to "export to Mypics"? The only way to get a Raw out of iPhoto is to export with the Kind set to Original.
    Regards
    TD

Maybe you are looking for