How to convert an embedded image to a bytearray

I have an image like this
[Embed(source="images/open_position.PNG")]
public var OpenImage:Class;
How can I convert this to a ByteArray?

Hi,
Your OpenImage class is a subclass of BitmapAsset, then you can retrieve the ByteArray by an instance of OpenImage. Here is the draft code (not tested):
public function getByteArray( InputClass:Class ):ByteArray {
     var instance:BitmapAsset = BitmapAsset( new InputClass() );
     return instance.bitmapData.getPixels();

Similar Messages

  • How do I define Embedded image in FLT XML?

    Hi,
    Let's say I have embedded an image like this:
    package
        public final class Resource
            [Embed (source="/assets/images/1.gif" )]
            public static const image_1:Class;
    How would I call this from FLT XML for the source to be correctly mapped to my image?
    <TextFlow xmlns="http://ns.adobe.com/textLayout/2008">
       <p>
           <img source="  ??  "/>
       </p>
    </TextFlow>
    Thanks in advance!

    There is no built in way to do that.  It can, however, be done in several ways.
    One way is to supply a custom Configuration to the importer that converts the XML to a TextFlow.  That configuration would include an inlineGraphicResolver function that would convert your markup to a DisplayObject.
    Another possibility would be to simply walk the markup after the import and modify the source of the various ILG objects.
    I'm kind of wondering though - can you new "StringNameOfClass"?
    The class and DisplayObject source specifications for ILGs are there mostly because it works.  They do have limitations with cut/copy/paste.  Class works within a SWF but not to an external swf.  There is no way in Flash to "clone" a generic DisplayObject.
    Hope that helps,
    Richard

  • How to convert JPEG - PNG images using java?

    Hi,
    Has anyone done this before?
    Can you provide me with a sample code or point me to the direction on how this can be done?
    Are there any existing Java technology that supports this?
    Most grateful. Thanks.

    It's should be easy using Java Advanced Imaging (JAI). Try this.
    import javax.media.jai.JAI;
    import javax.media.jai.RenderedOp;
    public class convert {
      static public void main(String[] args) {
        String inName = args[0];
        String outName = args[1];
        RenderedOp source = JAI.create("fileload", inName);
        JAI.create("filestore", source, outName, "PNG", null);
        System.exit(0);
    }

  • How to convert 24bits png image into 8 bits image

    Hi,
    I have gone through some of threads in this forum on changing color bits. But, I still can find right way to change my image (24bits) into different color bits(8 bits). The reason i want to change the color bits because I am getting a GIF image from map server, convert it into PNG format then rescale then into size of mobile phone screen.The PNG image is really has large data length , so the it took a while to load the whole image on screen.
    Note : The following code is taken from few threads in this forum and i have modified it to suit my application.
    I have no idea about Java2d...any help really appreciated...Thanks in advance!!!
    My code is as follow:-
    public File Scale(int width, int height, BufferedImage ImgSrc)
         try
                   //BufferedImage bi = ImageIO.read(ImgSrc);
                   //int w = bi.getWidth(), h = bi.getHeight();
         //Image oldRescale = bi.getScaledInstance(i, j, Image.SCALE_SMOOTH);
         BufferedImage Rescale = rescale(ImgSrc, width, height);
                   //ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
                   //ColorConvertOp op = new ColorConvertOp(cs, null);
                   //Rescale = op.filter(Rescale, null);
         File outfile = new File("map.png");
                   ImageIO.write(Rescale, "png", outfile);
                   BufferedImage fromFile = ImageIO.read(outfile);
                   ColorModel cm = fromFile.getColorModel();
                   System.out.println(cm.getClass() + ", bits/pixel=" + cm.getPixelSize());
              catch(Exception e)
                   e.printStackTrace();
              return new File("map.png");
         public static GraphicsConfiguration getDefaultConfiguration()
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    return gd.getDefaultConfiguration();
         public static BufferedImage copyRescaled(BufferedImage tgt, BufferedImage src)
              Graphics2D g2 = tgt.createGraphics();
    int w=tgt.getWidth(), h=tgt.getHeight();
    hintForBestQuality(g2);
         g2.drawImage(src, 0, 0, w, h, null);
         g2.dispose();
    return tgt;
    public static Graphics2D hintForBestQuality(Graphics2D g2)
    g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
              RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    g2.setRenderingHint(RenderingHints.KEY_RENDERING,
              RenderingHints.VALUE_RENDER_QUALITY);
    return g2;
         public static BufferedImage rescale(BufferedImage src, int w, int h)
    int transparency = src.getColorModel().getTransparency();
    GraphicsConfiguration gc = getDefaultConfiguration();
    BufferedImage tgt = gc.createCompatibleImage(w, h, transparency);
    return copyRescaled(tgt, src);

    First, we need to be clear about what you're trying to do -- is it rescale an
    image or insure that the image is saved with a 8bit pixel depth? Or both? You are also
    using GraphicsConfiguration's createCompatibleImage, which is excellent if you are going
    to display the image immediately because it might be hardware accelerated
    or compatible with hardware format, but you mentioned mobile phone screens, so
    there is no advantage to using GraphicsConfiguration in that case, and if fact, it's
    probably changing your ColorModel when you're not looking.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import java.io.*;
    import java.net.*;
    import javax.imageio.*;
    import javax.swing.*;
    public class Example {
        public static void main(String[] args) throws IOException {
            URL url = new URL("http://java.sun.com/developer/technicalArticles/GUI/JavaServerFaces/fig2.gif");
            BufferedImage image = ImageIO.read(url);
            System.out.println("image's colormodel = " + image.getColorModel().getClass());
            BufferedImage rescaled = scaleAndConvertColorModel(image, 0.75, null); //GIF => IndexColorModel
            System.out.println("rescaled's colormodel = " + image.getColorModel().getClass());
            File png = new File("junk.png");
            ImageIO.write(rescaled, "png", png);
            BufferedImage fromFile = ImageIO.read(png);
            System.out.println("fromFile's colormodel = " + image.getColorModel().getClass());
            JPanel cp = new JPanel(new GridLayout(0,1));
            addTo(cp, image, "original image");
            addTo(cp, rescaled, "rescaled image");
            addTo(cp, fromFile, "png file image");
            JFrame f = new JFrame("Example");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(cp);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
            Will rescale and convert colormodel if necessary.
            ColorModel == null => don't convert. May return src if suitable.
        public static BufferedImage scaleAndConvertColorModel(BufferedImage src, double scale, ColorModel cm) {
            int w0 = src.getWidth();
            int h0 = src.getHeight();
            int w = (int) (w0 * scale);
            int h = (int) (h0 * scale);
            ColorModel cm0 = src.getColorModel();
            if (cm == null)
                cm = cm0;
            if (w==w0 && h==h0 && cm.equals(cm0))
                return src;
            BufferedImage tgt = createImage(w, h, cm);
            Graphics2D g = tgt.createGraphics();
            if (scale < 1) {
                Image temp = src.getScaledInstance(w, h, Image.SCALE_AREA_AVERAGING);
                g.drawImage(temp, null, null);
            } else {
                hintForBestQuality(g);
                g.drawRenderedImage(src, AffineTransform.getScaleInstance(scale, scale));
            g.dispose();
            return tgt;
        public static BufferedImage createImage(int w, int h, ColorModel cm) {
            if (w <= 0 || h <= 0)
                throw new IllegalArgumentException("...");
            boolean alphaPremultiplied = cm.isAlphaPremultiplied();
            WritableRaster raster = cm.createCompatibleWritableRaster(w, h);
            return new BufferedImage(cm, raster, alphaPremultiplied, null);
        public static Graphics2D hintForBestQuality(Graphics2D g) {
            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
            g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
            return g;
        static void addTo(Container c, BufferedImage image, String title) {
            JLabel label = new JLabel(new ImageIcon(image));
            label.setBorder(BorderFactory.createTitledBorder(title));
            c.add(label);
    }

  • How to convert an pdf image into a jpeg

    I just purchased export pdf and I'm trying to convert from pdf to word or ppt.  The pdf is an image / logo that I want to make a jpeg.  I used the export utility and keep getting random characters and not an image. I'm guessing it's looking for text.  Do I have the right utility?

    I don't see converting to Word as the right way to go if you want a picture.
    Instead, view in Adobe Reader as large as possible, take a screen shot, paste in PAINT.

  • How to convert a CMYK image to pantone in Illustrator

    Is it possible to convert the CMYK raster image to pantone in illustrator.

    On Mon, 12 May 2008 22:37:41 -0700, [email protected] wrote:
    > Is it possible to convert the CMYK raster image to pantone in illustrator.
    I think you meant to post this to the illy group.
    Mike Russell - [advertising link deleted]

  • How to convert AviVideoFormat to  Image?

    Hello all,
    Anybody knows how can I do a conversion from AviVideoFormat to a BufferedImage to display?
    regards and hnaks in advance

    jp1963 wrote:
    Anybody knows how can I do a conversion from AviVideoFormat to a BufferedImage to display?
    regards and hnaks in advanceSince you were patient this time, I'll offer help.
    1) If you're wanting to simply display the video, just play it using a player.
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/SwingJMF.html]
    2) If you're wanting to access the image for the purposes of like, overlaying graphics on it dynamiclly,
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/FrameAccess.html]
    Will give you the ability to do that. Or just access the individual frames for whatever reason.

  • 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?

  • How to convert PNG image to Vertor Image to make font on Mac

    Hi Mac People,
    I like to create a set of font, and I have made them in a image editing tool, I have FontForge downloaded but decide to use it to convert instead direct design them inside.
    So now I don't know how to convert the PNG image to vector image required by the FontForge, I read some post mentioned Ubuntu has utilities to convert, but I'm not sure OS X has that function too.
    Could anyone let me know how to convert PNG so I can create my fonts?
    If PNG can't, the software can export TIFF or jpeg or similar.
    Please help me, I need make them this few day.
    Thanks everyone for giving me a hand!

    take a look at:
    http://developers.sun.com/techtopics/mobility/midp/articles/picture/

  • 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.

  • Rendering of embedded images

    <p>We are creating reports out of MS SQL. They contain besides tables and charts images that are showing maps. These images are created in MapInfo, saved to jpg and stored as BLOB in the database. On the maps are the results of cellular drive tests along routes. For each network operator we have one map. Before placing them into the DB they are all looking same (no tint).</p><p> <img src="http://portal.lws-cna.com/temp/sample1.jpg" alt=" " title="sample1 http://portal.lws-cna.com/temp/sample1.jpg" width="400" height="257" /><br /><a href="http://portal.lws-cna.com/temp/sample1.jpg">http://portal.lws-cna.com/temp/sample1.jpg</a></p><p><img src="http://portal.lws-cna.com/temp/sample3.jpg" alt=" " title="sample 3 http://portal.lws-cna.com/temp/sample3.jpg" width="400" height="257" /><br /><a href="http://portal.lws-cna.com/temp/sample3.jpg">http://portal.lws-cna.com/temp/sample3.jpg</a></p><p>As you can see the maps are showing the same area but different results. When I include them into the report they are tinted. I could reproduce this in an image processing tool by decreasing the color depth using different methods.</p><p>I wanted to understand how the rendering of embedded images works. Are there settings/measures to influence the rendering behavior?</p><p>Thanks, Joerg</p>

    Please re-post if this is still an issue and search forums first.

  • How to convert raster images like( PNG, JPG,GIF, BMP, TIFF etc) into SVG

    Hi Friends!
    With a hope that any Java Guru from SUN Forum can help me to solve my query, I'm posting my thread here.
    I have a project with feature to add image. My requirement is to convert any selected image file like (PNG,JPG,BMP,Tiff) into SVG Formate before adding it to Frame.
    I found one software from the link :
    http://delineate.sourceforge.net/
    Which covert raster to SVG.
    But I don't how can i use it runtime ?
    I want to convert during runtime process. like when user select option for to add Image then it call a procedure to add Image by converting any raster to svg & finally add to Frame.
    Your any help/suggestions wold be appreciated
    Regards
    Kirti

    There are basically two approaches:
    1. Embed the raster image in the SVG
    2. Vectorize the image
    1. Use Batik, or just write the XML yourself. Create some SVG files with embedded images, the syntax isn't to difficult. You could do it with a PrintWriter.
    2. Good luck to you. Writing a good vectorizer is
    - difficult
    - often pointless
    - though a great challenge if you're in to it
    The appllication you mention actually is only a front-end. it doesn't execute the vectorization itself. It uses Potrace and autotrace, which are native applications.

  • How can I programatically identify PDF files with embedded images?

    Our company has 27,266,949 .PDF files that we're planning to compress in order to save server space.
    We don't want to compress any of the .PDF files that have embedded images as to not alter the image's state.
    How can we programatically create a list to exclude from the compression process?

    Ah, see told you we were new to this and no, my taxs already have enough digits to the balance.
    Ok, so based on that, we should be able to use the preflighting tool to identify the PDF’s with images, factor them out, and then continue with lossless compression on the remaining balance.
    That will give us the compression we need to save space, but also allow us to stand in the court of law (if the scenario was to ever occur) and proclaim that none of our medical images have ever been altered by compression.
    Sound like a reasonable plan?

  • How can I use or convert a imaq image to plot images back on waveform graph

    Hi
    I am currently opening and manipulating (rotate and resize) a PNG image using IMAQ Vision in LabView 8.2.1 This works well and I can display the Image on the front panel using a IMAQ Image Control.
    In addition to this I would now like to display the image as a background on waveformgraph. I can do this with the original PNG file by reading it and then flatten it to a pixmap ie make it a Picture but this is of little use as I need to use the manipulated IMAQ image.
    Therefor I would like to know how to convert the manipulted IMAQ Image to right Picture Format (without resaving) in order to use it on the PlotImages.Back property node of a wavefrom graph.
    I very much welcome your suggestions as I feel it should be easy yet can not seem to solve it. Thank you for your time!!!

    Hi Randall
    Apologies for replying somewhat late but I have been out of the office for a few days.
    Your suggestions and code helped me greatly and led to solving my query so thank you for that.
    There is one more thing (well many many more but I will place new posts for those  however that you might be able to answer for me.
    Following your suggestion to use the image to array function I searched through more examples and found the code that did exactly what I wanted to do. Please see attached.
    In this code a For loop is used to add 65793 to the color table. It works very well but I do not know why it is used exactly. Can you exlplain? I also realize I never made it clear that I use grayscale PNG files rather then color images.
    Thanks again for your excellent help, it is much appreciated.
    Attachments:
    IMAQ_8-bit_to_picture v1.vi ‏15 KB
    Test Image.png ‏42 KB

  • I have Windows 7, Microsoft Outlook and PSE 13. I have used the "Share photos as embedded images" feature frequently, but today when I went to use it, it wasn't there, only the option to send email with files attached. How do I get back the ability to sen

    I have Windows 7, Microsoft Outlook and PSE 13. I have used the "Share photos as embedded images" feature frequently, but today when I went to use it, it wasn't there, only the option to send email with files attached. How do I get back the ability to send emails with photos embedded. I like adding the frames and backgrounds and I think it's easier for recipients to look at the photos. Thanks for any suggestions of things to try.
    Gail

    I had a similar problem in that my wife's iphone 5 could not send pics with imessage.  Had to set the settings to default to SMS or whatever.  After laboring many hours on the web I coincidentally was on the phone with the internet people to question my internet speed.  They changed the router channel, which is something that I am capable of doing myself.  After that, the pics go over imessage.  My own Iphone didn't have the problem.  We are both latest IOS 7.0.6.

Maybe you are looking for

  • Failure starting OAM Server

    I am getting the following error at startup and I cannot figure exactly what the error is telling me. The error is at the bottom. Any help would be appreciated. Thanks, Art C:\Java\jdk1.6.0_33\bin\java -client -Xms256m -Xmx512m -XX:CompileThreshold=8

  • WLC with LAG mode enable connected to a switch HP in LACP mode

    I am trying to connect a WLC 4402 5.0.148.0 mode with an HP 2800 switch. The switch is configured thunk mode with LACP protocol. The WLC in LAG mode uses the protocol LACP? How can configure them switch HP? Thanks. Mirko Severi.

  • Microsoft Click to Run won't open Microsoft Word Starter 2010

    The error message says it cannot open Microsoft Word Starter 2010 to try again or to repair in Control Panel.  I have no idea how to repair it.  Any suggestions? I am running Windows 7 Home with an HP 2000 notebook pc.  64 bit Operating System. Thank

  • Fail to access a modifed ISA B2B application

    Hi, I have an ISA B2B application (say b2b) in a remote server accessed by the link http://A.B.C.D:53200/b2b/b2b/init.do. Then I made a local copy called b2b_mod; made some minor changes and did the deploy with no problems so far. Using Visual Admin,

  • Activity form Problem

    Hi experts, I wanted to open Activity form on add button of my own form which is of no object . Please tell me how can i open the activity form using code.