Convert Canvas to Image in sapui5

Convert canvas to image using controller in sapui5,I have tried these codes but nothing works..Please help me.
Here is my code:
onOkCloseButton : function(oEvent) {
  var view = this.getView();
  var canvas = view.byId("canvas");
var dataURL = canvas.toDataURL("image/png");
// var window = window.open();
// window.document.write('<img src="'+dataURL+'"/>');
// window.location = (canvas.toDataURL('image/png'));
// var dataURL = canvas.toDataURL();
// $.post("http://localhost:31651/Registration_Card/index.html", { img : canvas.toDataURL() }) 
// .done(function(data) { 
//  alert("Image Sent to Server "); //on completion 
// Canvas2Image.saveAsJPEG(canvas);
// var oImgJPEG = Canvas2Image.saveAsJPEG(canvas, true);
// Canvas2Image.saveAsPNG(canvas, false, 100, 100);
  oEvent.getSource().getParent().close();

Ho to save a canvas as an image in J9 and CDC.
It seems that I already have resolute by means of the tool Jimi de Sun. Anyway I will thank for any new contribution.
Thanks

Similar Messages

  • Get canvas.toDataURL('image/jpeg') and convert base64 encoding to java.sql.Blob

    Convert canvas.toDataURL('image/jpeg') to java.sql.Blob.
    I am using oracle adf so I am able to action a backing bean from javascript and pass in parameters as a map. I pass in the canvas.toDataURL('image/jpeg') which I then try to decode in my bean. Using BASE64Decoder and the converting the bytearray to a file I can see the image is corrupted as I can't open the file thus converting the bytearray to blob is also a waste.
    Has anyone any ideas on base64 encoding from canvas.toDataURL to file or Blob?

    Use Case:
    A jsf page that enables a user to take photos using the HTML5 canvas feature - interact with webcam -, take photos and upload to profile
    1. I have created the jsf page with the javascript below; this pops up as a dialog and works okay and onclick an upload image, triggers the snapImage javascript function below and sends the imgURL parameter to the serverside managedbean
    <!-- java script-->
    function snapImage(event){
                    var canvas = AdfPage.PAGE.findComponent('canvas');
                    AdfCustomEvent.queue(event.getSource(),"getCamImage",{imgURL:canvas.toDataURL('image/jpeg'),true);
                    event.cancel();
    <!-- bean -->
    public void getCamImage(ClientEvent ce){
    String url=(String)ce.getAttributes().get("imgURL");
    decodeBase64URLToBlob(url);
    private BlobDomain decodeBaseB4URLToBlob(String url64){
                    BASE64Decoder de=new BASE64Decoder();
                    byte[] bytes=de.decode(url64);
                    File file=new File("abc.jpg");
                    InputStream in = new ByteArrayInputStream(bytes);
                    BufferedImage bImageFromConvert = ImageIO.read(in);
                    in.close();
                    ImageIO.write(bImageFromConvert, "jpg", file);
                    return createBlobDomainFromFile(file);
    ----problem---
    Accessing the generated jpeg file shows the image is corrupted, probably missing bytes or encode/decoder issues.and the blob image after uploading to database is saved as a binary stream which ondownload doesnt render as an image or anything i know of.
    Is there anyways of achieving the conversion without errors?

  • Need to convert byte[] to image

    hi frnds,
    i have a byte[](which i got it from an image) i need to convert back to image.Could u pls suggest me how to??
    i tried with Pixelgrabber but i exaclty did get wht shld be the input for it(tried giving image file name). :(
    So pls let me know how and wht to use..ASAP.
    Regards
    subinjava

    Subinjava wrote:
    ..i have a byte[](which i got it from an image) i need to convert back to image.Could u pls suggest me how to??
    Image image = Toolkit.getDefaultToolkit().createImage(byteArray)See http://java.sun.com/javase/6/docs/api/java/awt/Toolkit.html#createImage(byte[]) for more details.

  • Convert a Tiff Image to png and show

    Hello;
    I wanto to convert a Tif image to png and show this in my web page but i dont want to save the png iamge in my server.
    Actualy i do that:
    byte[] bytes = imagenData;
                    ByteArraySeekableStream tiffStrm = new ByteArraySeekableStream(bytes);
                    String[] CdcNms = ImageCodec.getDecoderNames(tiffStrm);
                    ImageDecoder tifDecoder = ImageCodec.createImageDecoder(CdcNms[0], tiffStrm, new TIFFDecodeParam());
    //                 Check the number of pages
                    int IFDs = tifDecoder.getNumPages();
    //                 Get the first page
                    RenderedImage ren = tifDecoder.decodeAsRenderedImage(1);
                    byte[] bytes2 = doSingleConversion(ren);AND
    protected byte[] doSingleConversion(RenderedImage tifImage) throws Exception
              byte[] bytes = null;
              String out = "temp.png";
              try {
                   //      Create the PNG file
                   PNGEncodeParam pngParm = PNGEncodeParam.getDefaultEncodeParam(tifImage);
                   JAI.create("filestore", tifImage, out, "PNG", pngParm);
                   //Read the file into a byte array
                   File f = new File(out);
                   FileInputStream in = new FileInputStream(f);
                   bytes = new byte[(int) f.length()];
                   in.read(bytes);
                   in.close();
                   return bytes;
              catch(Exception e) {
                   e.printStackTrace ();
                   throw(e);
         }But this code save de image in the server; it�s posible do it without save.

    Numbers the iWorks program? Not sure you can convert it to that or just a list of numbers. Never heard of anyone that would even want to convert an Image file, Photo, to any other format. Other then another image format like JPG, PNG or a PSD Photoshop file.

  • How to use a grayscale color model in converting a colored image

    how to convert a colored image into grayscale using :
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
    int bits[] = new int[] {8};
    ColorModel cm = new ComponentColorModel(cs, bits, false, false,
    Transparency.OPAQUE,
    DataBuffer.TYPE_BYTE);
    please only this method , i don't need the "bandcombine" method cause i need to know that i have exact 256 grayscale colors, thanx in advance.

    I went into mail preferences in the first place. I found the fonts and colors and picked the color I want but it doesn;t seem to be sticking?

  • Why is it so difficult to convert a Raw image to a jpeg in Photoshop Elements?!  I have version 12. Once i realised to change the tickbox in Camera Raw to 8 instead of 16 i did. Having spent time working on my Raw images i save them as a jpeg and rename t

    Why is it so difficult to convert a Raw image to a jpeg in Photoshop Elements ?! I have version 12. Once i realized to change the tick box in Camera Raw to 8 bit instead of 16 bit and Flatten image ( sometimes can flatten image if the flatten option isn't greyed out) hey presto i thought i was up and running. However after saving the photograph as a jpeg and renaming it e, after the word edit. I switched off/on my computer only for all the images i had spent time working on to have disappeared. Feeling very upset as there is no Technical Help to telephone at adobe and i don't know what to do.

    My daughter has had her Razr for about 9 months now.  About two weeks ago she picked up her phone in the morning on her way to school when she noticed two cracks, both starting at the camera lens. One goes completely to the bottom and the other goes sharply to the side. She has never dropped it and me and my husband went over it with a fine tooth comb. We looked under a magnifying glass and could no find any reason for the glass to crack. Not one ding, scratch or bang. Our daughter really takes good care of her stuff, but we still wanted to make sure before we sent it in for repairs. Well we did and we got a reply from Motorola with a picture of the cracks saying this was customer abuse and that it is not covered under warranty. Even though they did not find any physical damage to back it up. Well I e-mailed them back and told them I did a little research and found pages of people having the same problems. Well I did not hear from them until I received a notice from Fed Ex that they were sending the phone back. NOT FIXED!!! I went to look up why and guess what there is no case open any more for the phone. It has been wiped clean. I put in the RMA # it comes back not found, I put in the ID #, the SN# and all comes back not found. Yet a day earlier all the info was there. I know there is a lot more people like me and all of you, but they just don't want to be bothered so they pay to have it fix, just to have it do it again. Unless they have found the problem and only fixing it on a customer pay only set up. I am furious and will not be recommending this phone to anyone. And to think I was considering this phone for my next up grade! NOT!!!!

  • Problem in converting text to image.

    Hi I am trying to convert a text to image. The code for the same is pasted below. The problem is how do I change the background color. No matter what color I give with Graphics2D object, the background is always black. I want a white background.
    public class TextToImg1
    public static void main(String args[])
    try
    int width = 400;
    int height = 400;
    BufferedImage bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2D = bimage.createGraphics();
    g2D.drawString("This is the sample page to convert text to image.",100,100);
    g2D.setBackground(Color.WHITE);
    g2D.setColor(Color.WHITE);
    File f = new File ("anImage.jpg");
    ImageIO.write (bimage, "jpeg", f);
    catch(Exception exception)
    System.err.println(exception.getMessage());
    }

    Probably because you didn't draw the background. Use the fillRect(...) method to paint the background using the color your want.

  • Mail converts jpg/gif images to tiff

    I have a friend who has an ibook running panther. When she tries to forward an email message that contains jpg or gif attachments, Mail converts them to tiff, which causes problems for her windows bound friends, and also increases the message size by a factor of 10. Animated gif attachments converted to tif are useless.
    Is there any way for her to stop Mail from converting these attachments to tif? Thanks.

    Is there any way for her to stop Mail from converting these attachments to tif?
    Not with Jaguar or Panther Mail.
    This is caused by the sender using HTML for message composition and a jpg or gif being embedded in the message body which are not true attachments.
    Jaguar and Panther Mail render HTML received but do not support composing in HTML which includes when forwarding a message received that was composed in HTML. Jaguar/Panther Mail supports RTF and Plain Text only so when forwarding a message received that was composed in HTML with embedded images, the Mail.app converts the embedded images to attachments and uses RTF.
    Although Tiger Mail does not support complex HTML composition within the body of a message, RTF in Tiger Mail is HTML. Tiger Mail also supports forwarding a received message that was composed in HTML. With Safari under Tiger, you can select Mail Contents of This Page which will copy the selected web page and paste the contents in a new mail message and the contents of the copied web page will be sent in it's entirety.

  • Purchased the adobe product to convert a pdf image to a RTF file but cannot figure out to accomplis

    Bought the adobe product to convert a pdf image to an RTF file but cannot figure out how to get it to work

    HI wjleshe,
    I've checked your account using the email address that you use here in the forums, but I don't see any order history. Did you perhaps sign up with a different email address? Or did you sign up via the Reader mobile app for iOS or Android? If you got your subscription via an in-app purchase, Adobe wouldn't have record of your order. And, you would need to contact the app store if there is a problem with your subscription.
    Best,
    Sara

  • Converting cmyk compressed images to rgb compressed format

    Hi,
    I need some help in converting of CMYK images to RGB images. I got some sample code from internet but I get some run time exceptions with that and I'm not able to figure out the reason for the same. Pls help me in fixing the same. Any help will be sincerely appreicated.
    The code is given below :
    import java.awt.image.*;
    import java.awt.image.renderable.*;
    import java.awt.color.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.io.*;
    import java.net.*;
    import javax.media.jai.*;
    import com.sun.image.codec.jpeg.*;
    public class CMYKTest1 {
      public static void main(String args[]) throws Exception{
         RenderedOp op = JAI.create("fileload", "Kristopher Brock LOGO.jpg");
         ColorModel rgbcm = op.getColorModel();
         ICC_Profile profile = ICC_Profile.getInstance("CMYK.pf");
    //     ICC_Profile profile = ICC_Profile.getInstance(ColorSpace.TYPE_CMYK);
         ICC_ColorSpace icp = new ICC_ColorSpace(profile);
         ColorModel colorModel =
              RasterFactory.createComponentColorModel(op.getSampleModel().getDataType(),
                                                                icp,
                                                                false,
                                                                false,
                                                                Transparency.OPAQUE);
         ImageLayout il = new ImageLayout();
         il.setSampleModel(colorModel.createCompatibleSampleModel(op.getWidth(),
                                                                                op.getHeight()));
         RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il);
         ParameterBlock pb = new ParameterBlock();
         pb.addSource(op).add(colorModel);
         op = JAI.create("ColorConvert", pb, hints);
         pb = new ParameterBlock();
         pb.addSource(op).add(rgbcm);
         il = new ImageLayout();
         il.setSampleModel(rgbcm.createCompatibleSampleModel(op.getWidth(),
                                                                          op.getHeight()));
         hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il);
         op = JAI.create("ColorConvert", pb, hints);
         JAI.create("filestore", op, "earthrgb.jpg", "JPEG", null);
         BufferedImage img = op.getAsBufferedImage(null, null);
         OutputStream fout = new FileOutputStream("earthrgb1.jpg");
         JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fout);
         JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(img);
         param.setQuality(1, false);
         param.setXDensity(300);
         param.setYDensity(400);
         encoder.encode(img, param);
         fout.close();
    }I get the following error:
    Caused by: java.lang.IllegalArgumentException: Numbers of source Raster bands and source color space components do not match
         at java.awt.image.ColorConvertOp.filter(Unknown Source)
         at com.sun.media.jai.opimage.ColorConvertOpImage.computeRectNonColorSpaceJAI(ColorConvertOpImage.java:373)
         at com.sun.media.jai.opimage.ColorConvertOpImage.computeRect(ColorConvertOpImage.java:290)
         at javax.media.jai.PointOpImage.computeTile(PointOpImage.java:914)
         at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
         at javax.media.jai.OpImage.getTile(OpImage.java:1129)
         at javax.media.jai.PointOpImage.computeTile(PointOpImage.java:911)
         at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
         at javax.media.jai.OpImage.getTile(OpImage.java:1129)
         at com.sun.media.jai.codecimpl.JPEGImageEncoder.encode(JPEGImageEncoder.java:173)
         at com.sun.media.jai.opimage.EncodeRIF.create(EncodeRIF.java:70)
         ... 24 more
    Error: One factory fails for the operation "filestore"
    Occurs in: javax.media.jai.ThreadSafeOperationRegistry
    java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122)
         at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674)
         at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473)
         at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:332)
         at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:819)
         at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:867)
         at javax.media.jai.RenderedOp.getRendering(RenderedOp.java:888)
         at javax.media.jai.JAI.createNS(JAI.java:1099)
         at javax.media.jai.JAI.create(JAI.java:973)
         at javax.media.jai.JAI.create(JAI.java:1668)
         at CMYKTest1.main(CMYKTest1.java:79)
    Caused by: javax.media.jai.util.ImagingException: All factories fail for the operation "encode"
         at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1687)
         at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473)
         at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:332)
         at com.sun.media.jai.opimage.FileStoreRIF.create(FileStoreRIF.java:138)
         ... 15 moreThanks & Regards,
    Magesh.

    The following code converts an cmyk jpeg image into an rgb jpeg image.
    The only problem if this code is that it loads the whole image in memory and thus you'll need a lot of RAM when converting large images. For example, it take around 300 MB to convert a 3000*3800px image (this is a 5MB jpeg image when compressed on disk).
    import com.sun.image.codec.jpeg.JPEGImageEncoder;
    import com.sun.image.codec.jpeg.JPEGCodec;
    import com.sun.image.codec.jpeg.JPEGEncodeParam;
    import javax.imageio.ImageIO;
    import javax.imageio.ImageReader;
    import javax.imageio.stream.ImageInputStream;
    import javax.imageio.metadata.IIOMetadata;
    import javax.imageio.metadata.IIOMetadataNode;
    import java.util.*;
    import java.io.*;
    import java.awt.image.*;
    import java.awt.*;
    import java.awt.color.ColorSpace;
    import org.w3c.dom.NodeList;
    public class Test {
        public static void main(String[] args) throws Exception {
            BufferedImage i1 = readImage(new File("cmyk.jpg"));
            BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(new File("rgb.jpg")));
            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
            JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(i1);
            param.setQuality(1, false);
            encoder.setJPEGEncodeParam(param);
            encoder.encode(i1);
        public Test() {
        // extract metadata
        public static BufferedImage readImage(File file) throws IOException {
            // Get an ImageReader.
            ImageInputStream input = ImageIO.createImageInputStream(file);
            Iterator readers = ImageIO.getImageReaders(input);
            if (readers == null || !readers.hasNext()) {
                throw new RuntimeException("No ImageReaders found");
            ImageReader reader = (ImageReader) readers.next();
            reader.setInput(input);
            String format = reader.getFormatName();
            if ("JPEG".equalsIgnoreCase(format) || "JPG".equalsIgnoreCase(format)) {
                IIOMetadata metadata = reader.getImageMetadata(0);
                String metadataFormat = metadata.getNativeMetadataFormatName();
                IIOMetadataNode iioNode = (IIOMetadataNode) metadata.getAsTree(metadataFormat);
                NodeList children = iioNode.getElementsByTagName("app14Adobe");
                if (children.getLength() > 0) {
                    iioNode = (IIOMetadataNode) children.item(0);
                    int transform = Integer.parseInt(iioNode.getAttribute("transform"));
                    Raster raster = reader.readRaster(0, reader.getDefaultReadParam());
                    if (input != null) {
                        input.close();
                    reader.dispose();
                    return createJPEG4(raster, transform);
            throw new RuntimeException("No ImageReaders found");
         * Java's ImageIO can't process 4-component
         * images
         * <p/>
         * and Java2D can't apply AffineTransformOp
         * either,
         * <p/>
         * so convert raster data to
         * RGB.
         * <p/>
         * Technique due to MArk
         * Stephens.
         * <p/>
         * Free for any
         * use.
        private static BufferedImage createJPEG4(Raster raster, int xform) {
            int w = raster.getWidth();
            int h = raster.getHeight();
            byte[] rgb = new byte[w * h * 3];
            // if (Adobe_APP14 and transform==2) then YCCK else CMYK
            if (xform == 2) {    // YCCK -- Adobe
                float[] Y = raster.getSamples(0, 0, w, h, 0, (float[]) null);
                float[] Cb = raster.getSamples(0, 0, w, h, 1, (float[]) null);
                float[] Cr = raster.getSamples(0, 0, w, h, 2, (float[]) null);
                float[] K = raster.getSamples(0, 0, w, h, 3, (float[]) null);
                for (int i = 0, imax = Y.length, base = 0; i < imax; i++, base += 3) {
                    float k = 220 - K, y = 255 - Y[i], cb = 255 - Cb[i], cr = 255 - Cr[i];
    double val = y + 1.402 * (cr - 128) - k;
    val = (val - 128) * .65f + 128;
    rgb[base] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff : (byte) (val + 0.5);
    val = y - 0.34414 * (cb - 128) - 0.71414 * (cr - 128) - k;
    val = (val - 128) * .65f + 128;
    rgb[base + 1] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff : (byte) (val + 0.5);
    val = y + 1.772 * (cb - 128) - k;
    val = (val - 128) * .65f + 128;
    rgb[base + 2] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff : (byte) (val + 0.5);
    else {
    // assert xform==0: xform;
    // CMYK
    int[] C = raster.getSamples(0, 0, w, h, 0, (int[]) null);
    int[] M = raster.getSamples(0, 0, w, h, 1, (int[]) null);
    int[] Y = raster.getSamples(0, 0, w, h, 2, (int[]) null);
    int[] K = raster.getSamples(0, 0, w, h, 3, (int[]) null);
    for (int i = 0, imax = C.length, base = 0; i < imax; i++, base += 3) {
    int c = 255 - C[i];
    int m = 255 - M[i];
    int y = 255 - Y[i];
    int k = 255 - K[i];
    float kk = k / 255f;
    rgb[base] = (byte) (255 - Math.min(255f, c * kk + k));
    rgb[base + 1] = (byte) (255 - Math.min(255f, m * kk + k));
    rgb[base + 2] = (byte) (255 - Math.min(255f, y * kk + k));
    // from other image types we know InterleavedRaster's can be
    // manipulated by AffineTransformOp, so create one of
    // those.
    raster = Raster.createInterleavedRaster(new DataBufferByte(rgb, rgb.length), w, h, w * 3, 3, new int[]{0, 1, 2}, null);
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorModel cm = new ComponentColorModel(cs, false, true, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
    return new BufferedImage(cm, (WritableRaster) raster, true, null);

  • How convert a big image to parts of images? means split a jpg image to several sub imges.(thi​s sub image can joint into that big image)

    hi friends..
    how convert a big image to parts of images? means split a jpg image to several sub imges.(this sub images can joint into that big image) any help
    Solved!
    Go to Solution.

    In the example, i have created two images and added them together, and the converse can be done in the same way.
    Thanks
    uday,
    Please Mark the solution as accepted if your problem is solved and help author by clicking on kudoes
    Certified LabVIEW Associate Developer (CLAD) Using LV13

  • Converting a PNG image to an array of bytes and vice versa..

    hi all,
    i need to convert a PNG image to an array of bytes ,then converting back this array of bytes to The PNG image again ,i read this can be done using output streams but i feel like a dump and i can't fix the whole thingy out ! ,can anybody help me in this ,by explaining how can this be established????
    Regards,
    D.Roth

    hi all,
    i need to convert a PNG image to an array of bytes ,then converting back this array of bytes to The PNG image again ,i read this can be done using output streams but i feel like a dump and i can't fix the whole thingy out ! ,can anybody help me in this ,by explaining how can this be established????
    Regards,
    D.Roth

  • "Convert colors" degrades image quality?

    I'm using Acrobat Professional 8 to convert a pdf file to the U.S. Web  Coated (SWOP) v2 color space. Strangely enough, when executing the color  convert, the JPEG image quality seems to degrade (see  attached image). Is there any way to prevent or minimize this quality  loss?

    Okay do you have an original of the design.
    try saving in 300 or 600 DPI  create the pdf.
    the try adding the Graphic
    Click on Tools menu Content editing
    next click on add image
    locate the image.
    Now place the image approximately where it should be.
    then choose the image and place in desired area.
    Save
    see if image looks better.

  • Need conversion mechanism for converting 24 bit image to 16 bit

    In my java project I need to convert 24 bit image to 16 bit image. I don't have any clue. Please provide me the option to implement it.
    Thanks,
    jai

    That doesn't tell me much, and I know what you're talking about. I doubt that it tells the OP anything useful whatsoever.Sorry EJP, it was a mouthful I know. Maybe this will help instead, a ColorConversionOps class to work on *32 bit > 16 bit > 32 bit colors*. To help clarify where the 16 bit color input and output goes, some of the methods return or require parameters of type short. Also take notice the bitmask for variables of type short vs the bitmasks for int. AND pay particular attention to the unsigned right bit-shifting of the most-significant-digit.
    public class ColorConversionOps
      public static short convert32_16(int rgb) {
        int a = ((rgb & 0xF0000000) >>> 16);
        int r = ((rgb & 0x00F00000) >>  12);
        int g = ((rgb & 0x0000F000) >>   8);
        int b = ((rgb & 0x000000F0) >>   4);
        return (short)( a | r | g | b);
      public static int convert16_32(short rgb) {
        int a = ((rgb & 0xF000) << 16);
        int r = ((rgb & 0x0F00) << 12);
        int g = ((rgb & 0x00F0) <<  8);
        int b = ((rgb & 0x000F) <<  4);
        return (a | r | g | b);
      public static void printRGB_32(int rgb) {
        System.out.println("a="+((rgb & 0xFF000000) >>> 24));
        System.out.println("r="+((rgb & 0x00FF0000) >>  16));
        System.out.println("g="+((rgb & 0x0000FF00) >>  8));
        System.out.println("b="+ (rgb & 0x000000FF));
        System.out.println();
      public static void printRGB_16(short rgb) {
        System.out.println("a="+((rgb & 0xF000) >>> 12));
        System.out.println("r="+((rgb & 0x0F00) >>  8));
        System.out.println("g="+((rgb & 0x00F0) >>  4));
        System.out.println("b="+ (rgb & 0x000F));
        System.out.println();
    }Now to make the conversion from 32 bit color to 16 bit color and back. NOTICE there willl be a loss of precision -- just like someone else has already said.
    public class Test
      public static void main(String[] args)
        int rgb = 0xFFFFFFFF;
        ColorConversionOps.printRGB_32(rgb);
        //a=255
        //r=255
        //g=255
        //b=255
        rgb = ColorConversionOps.convert32_16(rgb);
        ColorConversionOps.printRGB_16((short)rgb);
        //a=15
        //r=15
        //g=15
        //b=15
        rgb = ColorConversionOps.convert16_32((short)rgb);
        ColorConversionOps.printRGB_32(rgb);
        //a=240
        //r=240
        //g=240
        //b=240
    }And now we see, the reason 16bit color is so unpopular to the rest of the world, but not for us here!

  • WDJ convert base64binary to image

    Hi Guys,
    I have an issue where I want to display an image that is stored in a base64binary Business Object attribute on an application service and convert it back to an image on the WDJ view.
    I have tried first displaying the response content as text, what comes back seems to be a relative path i.e. ../../folder1/folder2/image.jpg
    followed by a whole stream of session-id looking numbers.
    That obviously didnt work as it was relative & i tried adding the correct start for the path but that didnt work either.
    I then tried looking at taking the .toString() of the response attribute & setting that as reference for an image. Unfortunately that doesnt work either.
    I'm now stuck with ideas. I know that it is possible as the WS Navigator can provide the file as a download.
    Any ideas or pointers for where to look.
    Also, any thoughts about whether base64binary is the right attribute to be storing the image as.
    Cheers.
    Edited by: Kelsall Mark on May 26, 2010 5:47 PM

    hey Kelsall,
    I have came across a thread on sun java forum [converting base64binary to image|/thread/5161771 [original link is broken];. Hope this would help.
    please let me know status,
    Good Luck,
    Nikhil

Maybe you are looking for

  • Data is not saving

    I am using Form 9i. I have 19 blocks and 6 canvas of which 5 blocks viz. 1) :WORKORDER_MASTER - are used for master record of workorder. 2) :WORKORDER_DTLS - are used for labour working under workorder. 3) :WORKODER_MASTER_IMG - image of authorised r

  • Couldn't get personal hotspot to work

    I tried the personal hotspot tonight for the first time (it is supported on my carrier - AU in Japan) but I couldn't get it to work. The restaurant I was in had wifi that my iPhone automatically connected to. I think that was one issue. For the perso

  • Seeking advice on Zone design

    I have a ZCM Zone originally built with ZCM 10.2 and has been updated over the years to 11.2.3 and soon to be updated to 11.3.1 The Zone services 15,000 devices with over 30k users (school district). The network topology is central, each school has a

  • Order types, why do we need to create our order types and not use the stand

    HI Order types, why do we need to create our order types and not use the standard ones during implementation.

  • How to Create a Clean oraInventory in Release 12 [ID 834894.1]

    Hi hussein/helios, I tried the above procedure, but the oracle_homes can not be added to the inventory.xml hence my opatch -lsinventory still fails: Result: LsInventory: OPatch Exception while accessing O2O OPATCH_JAVA_ERROR  : An exception of type "