Deriving color space of an image from a byte array input stream.

I was wondering, is it possible to derive the color space of an image, i.e. RGB, YCC, GRAY by calculating its bytes?

Calculate bytes just means doing operations on the
byte values. That's how I got the height and width of
the image. Now, I'm wondering if it is possible for
the color space.Look at the format specifications...
By the way, do all image file types have different
color space or could they all have the same color
space, for example, RGB?They can have different color spaces. RGB, ARGB, CMYK, some Adobe format...

Similar Messages

  • To create images continuously using a byte array  while streaming video

    Can someone please help me in creating images from a byte array continuously which is required while streaming video on implementation of RTP?

    seems like this could be the class you want to look at
    Package javax.imageio

  • How to set color space to JPEG image with Java advance Imaging

    How to set color space to JPEG image with Java advance Imaging.
    is there any API in JAI which support to set color space.

    I'm definately no guru, but this is how you can change it.
    CTRL + ALT + Click on the part of the component that you want to change. This brings up the Hidden Dom Inspector, background of component will be surrounded with a red outline (Make sure the red outline is surrounding the part of the tabset you want to change), Now you go to properties sheet and click the ellipses next to rules property this will pop up a dialog you look in this list (At the top) to see the default style classes that are affecting the rendering of the component outlined in red. (You will be able to select different sections of a single component) then you just rewrite the style class that you want to change in your Stylesheet (You will not find the styleclass that you want to change because it is a part of your theme .jar but as long as you name it exactly the same and place in your stylesheet it will override the theme .jar style classes) it's actually very easy -- you were right should be a piece of cake for a guru. Don't have the link handy but you can check out Winston's Blog on changing Table Formatting to get this information...It is EXTREMELY useful if you want your apps to have a custom look and not default that comes with Creator Themes.
    Hope this helps you out God knows others have helped me alot!
    Jason

  • How to remove blank data from a byte array

    Hi All,
    How to remove blank data from a byte array. Suppose I created a byte array as byte[] b = new byte[8192] and i read the data as inputstream.read(b). If the data that has been received is only 1000 bytes length, how to find out how much data has been read or how to delete that blank 7192 bytes of data?
    Thanking you,
    Regards,
    Shankar.

    1) Always try to sidestep this by allocating only the necessary amount of space required...
    2) If 1 is not possible, you will have to index byte for byte how much data was read into the array which
    denotes reading byte for byte... not ideal as this is relatively slow...
    Are you reading from a file?

  • How to convert a Image object to byte Array?

    Who can tell me, how to convert Image object to byte Array?
    Example:
    public byte[] convertImage(Image img) {
    byte[] b = new byte...........
    return b;

    Hello,
    any way would suit me, I just need a way to convert Image or BufferedImage to a byte[], so that I can save them. Actually I need to save both jpg and gif files without using any 3rd party classes. Please help me out.
    thanx and best wishes

  • Match color space when opening image in photoshop

    hi, i have new macbook air and when i export image from lightroom as TIFF (pro photo RGB) and import to photoshop, it asks what to do that embedded color space does not match with settings, therefore i changed that in photoshop (edit/color settings to pro photo rGB ), however my question is:  if there is any problem because my notebook display is set (system preferences) to "color LCD"
    when i set my display as pro photo RGB, it base blue tone, i must use Apple's preset called "colour LCD"

    Good day!
    if there is any problem because my notebook display is set (system preferences) to "color LCD"
    Your screen profile should generally not be set to your RGB Working Space as this would kind of negate Color Management.
    And in the absence of a proper custom profile the maker’s default profile seems to be a valid choice.
    Regards,
    Pfaffenbichler

  • Color Space on Thumbnail Image Variants

    Hi all-
    I'm loading some CMYK images into my repository (5.5 SP05) and trying to use the default thumbnail variant in a web application. For some reason, even though the color space of the thumbnail is set to RGB, it doesn't get converted when the thumbnail is created. This results in a .jpg  that is CMYK (and isn't understood by a browser).
    If I create a custom variant as .jpg and of the RGB color space, it works fine after generation. Is this a bug? Or is there a way to force the generation of thumbnails? I was trying to not have too many variants in my repository because I was worried about bloating it. Perhaps this shouldn't be a concern, but it still seems as if the thumbnail should get converted to RGB according to the settings in the Console. Any thoughts?
    Thanks
    Tim

    Tim,
    Sounds like this may be a bug. Since the Thumbnails are set to RGB, and cannot be changed, it seems as though they should be generated in RGB color space.
    One thing to try. Go into the images table, right click on an image in the records window, and select Generate Thumbnail. I believe it will actually regenerate the thumbnail. Maybe this will regenerate with the RGB color space. That's my only idea. Other than that you really don't have much control over the thumbnails.
    Regards,
    Tim

  • Color Space info for images

    Hi all,
    I would like to show the color space details for an image. Do you know what field mapping is required?
    Thanks,
    A.

    >> images are still a bit washed out with a warmish/ yellow cast to them, particularly, my black and white images
    Here is a simple test to help evaluate if the monitor profile is reasonably good:
    Open a RGB file in Photoshop (flatten if not already flattened).
    Press M key> Drag a selection> Com+Shift+U (Desaturate).
    Com+Z (to toggle back and forth).
    If the unsaturated selection looks neutral you've got a reasonably fair monitor profile.
    If selection has color casts (not neutral) -- you have a bad monitor profile
    +++++
    Here is a simple test to help evaluate if a bad monitor profile is whacking out your Photoshop color:
    Monitors/Displays (control panel)> Color> highlight AppleRGB or sRGB (don't run Calibrate), quit and reboot.
    If the Photoshop colors are back under control, then the problem was most surely a bad monitor profile go back into Monitors/Displays> Color and Calibrate a good profile highlight (load) sRGB, or preferably, the monitor's OEM profile as a starting point.
    If you are using a puck, it is likely defective; or your monitor hardware is the culprit...search it on Google by model number

  • Selected color profile for new images from "clipboard" is wrong in CS6

    I have given up trying to find the answer to this myself.
    Steps to reproduce:
    1. Take a screenshot of something in your web browser (macintosh CMD+SHIFT+4) to the clipboard.
    2. Select File > New from the menu. Clipboard should be the selected Preset.
    3. Notice how in CS6 the color profile under "Advanced" is "Display" and NOT "sRGB" — in CS5 it is sRGB.
    4. Paste from the clipboard into your new document and get the color profile mis-match warning if you are in CS6.
    It is either not picking the color space of the clipboard properly like it will in CS5, or I am missing something somewhere.
    Nothing I do in an attempt to fix this is working. I have sRGB set as my default profile in color settings, and nothing I do changes this setting for the "Clipboard" preset.
    I am getting sick of forgetting to manually select "sRGB" every time, opening up a new document sized to my clipboard and then getting the color profle mismatch warning when I paste in the clipboard contents!
    I take so many screenshots as I develop websites this is a CONSTANT problem as I am constantly creating new documents from the clipboard to check alignments, zoom in to get color samples, and many other reasons.
    Message was edited by: DrunkCyclist

    That helps a little. It explains why "Display" is selected when I create a new from the clipboard in PS.
    The ColorSync profile from a screenshot opened in the Preview App shows up as "Color LCD" in the inspector.
    So, I assume what is happening in PS is that the new document is being created in the working color space and my clipboard contents don't match that and therefore causes the warning?
    I could see getting a warning if I create a new document from the clipboard in PS and it embeds the "Display" profile within it, and then I try and paste something which has an sRGB (or other) embedded profile, but I was assuming the new document from the clipboard contents would have the same color profile as the clipboard contents.
    I just don't get why I get a warning when I create the new document and the very first thing I try and do is paste the clipboard contents into said document.
    However, when I select "sRGB" from the dropdown list instead of "Display" in the PS dialogue box it does not give me the mismatch warning.
    Although the warning does say my source and destination document are both using the "Display" profile but my working space is sRGB.
    The more I think about it, I may have just checked the "Don't show again" box in CS5 if I ever had the same issues and therefore never dealt with that again!
    I am going to go read as much as I can about the color profiles in PS. I used to deal with this a lot as a print designer but not so much anymore working in UI design. I only really look into these issues when I get weird color shifts on saved files and things of that nature.
    Thanks for taking the time to explain some things!

  • Error when creating BufferedImage with IndexColorModel from a byte array.

    Hi, I have a 1-dimentional byte array and an IndexColorTable, and I can't figure out how to combine the 2 into an BufferedImage without unnecessary copying/reallocating of the image buffer.
    The color model I have is:
    int [] cmap = new int [numColors];
    cmap[i++] = 0xffa0f000;  /etc.
    new IndexColorModel(8, 22, cmap, 0, true,  transparentIndex,  DataBuffer.TYPE_BYTE );Thanks for your help
    -Ben
    Ps.
    I've was looking at some example code (http://javaalmanac.com/egs/java.awt.image/Mandelbrot2.html?l=rel), and can't figure out how to go from the color model they're using to the one I have (the 8 bit one specified above). When I replace the 4bit colormodel in the code below with the 8bit color model specified above, I get the following error:
    [java] java.lang.IllegalArgumentException: Raster ByteInterleavedRaster: width = 5120 height = 3520 #numDataElements 1 dataOff[0] = 0 is incompatible with ColorModel IndexColorModel: #pixelBits = 8 numComponents = 4 color space = java.awt.color.ICC_ColorSpace@c51355 transparency = 2 transIndex = 22 has alpha = true isAlphaPre = false
    [java] at java.awt.image.BufferedImage.<init>(BufferedImage.java:613)
    Code:
    byte[] pixelArray = (byte[]) getData_CHAR();                
    int width = 5120;
    int height = 3520;
    int numbytes = width*height;
    //create DataBuffer using byte buffer of pixel data.
    DataBuffer dataBuffer = new DataBufferByte(pixelArray, numbytes, 0);
    //prepare a sample model that specifies a storage 8-bits of pixel data in an 8-bit data element
    int bitMasks[] = new int[]{0xf};
    SinglePixelPackedSampleModel sampleModel = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, width, height, bitMasks);
    //create a raster using the sample model and data buffer
    WritableRaster writableRaster = Raster.createWritableRaster(sampleModel, dataBuffer, new Point(0,0));
    //generate 16-color model
    byte[] r = new byte[16];
    byte[] g = new byte[16];
    byte[] b = new byte[16];
    r[0] = 0; g[0] = 0; b[0] = 0;
    r[1] = 0; g[1] = 0; b[1] = (byte)192;
    r[2] = 0; g[2] = 0; b[2] = (byte)255;
    r[3] = 0; g[3] = (byte)192; b[3] = 0;
    r[4] = 0; g[4] = (byte)255; b[4] = 0;
    r[5] = 0; g[5] = (byte)192; b[5] = (byte)192;
    r[6] = 0; g[6] = (byte)255; b[6] = (byte)255;
    r[7] = (byte)192; g[7] = 0; b[7] = 0;
    r[8] = (byte)255; g[8] = 0; b[8] = 0;
    r[9] = (byte)192; g[9] = 0; b[9] = (byte)192;
    r[10] = (byte)255; g[10] = 0; b[10] = (byte)255;
    r[11] = (byte)192; g[11] = (byte)192; b[11] = 0;
    r[12] = (byte)255; g[12] = (byte)255; b[12] = 0;
    r[13] = (byte)80; g[13] = (byte)80; b[13] = (byte)80;
    r[14] = (byte)192; g[14] = (byte)192; b[14] = (byte)192;
    r[15] = (byte)255; g[15] = (byte)255; b[15] = (byte)255;
    //create buffered image    
    ColorModel colorModel = new IndexColorModel(4, 16, r, g, b);
    BufferedImage image = new BufferedImage(colorModel, writableRaster, false, null);Message was edited by:
    ben_weisburd
    Message was edited by:
    ben_weisburd

    I had the same problem too.
    anyone found the solution for this problem?
    thanks
    Bruno Rabino
    When I try to make a MD-form, where the base-table for the detail contains a column with a BLOB-datatype. I get following error when I finish creation of the form.
    Error: Exception from wwv_generate_component.build_procedure (WWV-01821)
    Error creating module: ORA-01403: no data found (WWV-16042)
    When I use the table with the BLOB as master or in a form, it works fine.
    Has anyone else experienced this problem? Or knows a way to fix or work around it. Thanks in advance.
    Portal version: 3.0.6.6.5
    null

  • Display an object of Image type or Byte Array

    Hi, lets say i got an image stored in the Image format or byte[]. How can i make it display the image on the screen by taking the values in byte array or Image field?

    Thanks rahul,
    The thing is, i am generating a chart in a servlet
    and setting the image in the form of a byte [] to the
    view bean ( which is binded to the jsp, springs
    framework ). The servlet would return the view bean
    to the jsp and in the jsp, i am suppose to print this
    byte array so as to give me the image..
    I hope this makes sense.. pls help me ou!Well letme see if i got tht right or not,
    you are trying to call Your MODEL (Business layer / Spring Container) from a servlet and you are expressing that logic in form of chart (Image) and trying to save it as a byte array in a view bean and you want to print /display that as an image in a jsp (After Servlet fwd / redirect action) which includes other data using a ViewBean.
    If this is the case...
    As the forwaded JSP can include both image and Textual (hypertext too)..we can try a work around hear...Lets dedicate a Servlet which retreives byte [] from a view bean and gives us an image output. hear is an example and this could be a way.
    Prior to that i'm trying to make few assumptions here....
    1).The chart image which we are trying to express would of format JPEG.
    2).we are trying to take help of<img> tag to display the image from the image generating servlet.
    here is my approach....
    ViewBean.java:
    ============
    public class ViewBean implements serializable{
    byte piechart[];
    byte barchart[];
    byte chart3D[];
    public ViewBean(){
    public byte[] getPieChart(){
    return(this.piechart);
    public byte[] getBarChart(){
    return(this.barchart);
    public byte[] get3DChart(){
    return(this.chart3D);
    public void setPieChart(byte piechart[]){
    this.piechart = piechart;
    public void setBarChart(byte barchart[]){
    this.barchart = barchart;
    public void set3DChart(byte chart3D[]){
    this.chart3D = chart3D;
    }ControllerServlet.java:
    =================
    (This could also be an ActionClass(Ref Struts) a Backing Bean(Ref JSF) or anything which stays at the Controller Layer)
    public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException{
    /* There are few different implementations of getting   BeanFactory Resource
    In,the below example i have used XmlBeanFactory Object to create an instance of (Spring) BeanFactory */
    BeanFactory factory =
    new XmlBeanFactory(new FileInputStream("SpringResource.xml"));
    //write a Util Logic in your Implementation class using JFreeChart (or some open source chart library) and express the images by returning a  byte[]
    ChartService chartService =
    (GreetingService) factory.getBean("chartService");
    ViewBean vb = new ViewBean();
    vb.setPieChart(chartService.generatePieChart(request.getParameter("<someparam>"));
    vb.setBarChart(chartService.generateBarChart(request.getParameter("<someparam1>"));
    vb.set3DChart(chartService.generate3DChart(request.getParameter("<someparam2>"));
    chartService = null;
    HttpSession session = request.getSession(false);
    session.setAttribute("ViewBean",vb);
    response.sendRedirect("jsp/DisplayReports.jsp");
    }DisplayReports.jsp :
    ================
    <%@ page language="java" %>
    <html>
    <head>
    <title>reports</title>
    </head>
    <body>
    <h1 align="center">Pie Chart </h1>
    <center><img src="ImageServlet?req=1" /></center>
    <h1 align="center">Bar Chart </h1>
    <center><img src="ImageServlet?req=2" /></center>
    <h1 align="center">3D Chart</h1>
    <center><img src="ImageServlet?req=3" /></center>
    </body>
    </html>ImageServlet.java
    ==============
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
           byte buffer[];
            HttpSession session = request.getSession(false);
            ViewBean vb = (ViewBean) session.getAttribute("ViewBean");
            String req = request.getParameter("req");
            if(req.equals("1") == true)       
                buffer = vb.getPieChart();
            else if(req.equals("2") == true)
                 buffer = vb.getBarChart();
            else if(req.equals("3") == true)
                 buffer = vb.get3DChart();
            JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(new ByteArrayInputStream(buffer));
            BufferedImage image =decoder.decodeAsBufferedImage() ;
            response.setContentType("image/jpeg");
            // Send back image
            ServletOutputStream sos = response.getOutputStream();
            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(sos);
            encoder.encode(image);
        }Note: Through ImageServlet is a Servlet i would categorise it under presentation layer rather to be a part of Controller and added to it all this could be easily relaced by a reporting(BI) server like JasperServer,Pentaho,Actuate................
    Hope the stated implementation had given some idea to you....
    However,If you want to further look into similar implementations take a look at
    http://www.swiftchart.com/exampleapp.htm#e5
    which i believe to be a wonderful tutor for such implementations...
    However, there are many simple (Open) solutions to the stated problem.. if you are Using MyFaces along with spring... i would recommend usage of JSF Chart Tag which is very simple to use all it requires need is to write a chart Object generating methos inside our backing bean.
    For further reference have a look at the below links
    http://www.jroller.com/page/cagataycivici?entry=acegi_jsf_components_hit_the
    http://jsf-comp.sourceforge.net/components/chartcreator/index.html
    NOTE:I've tried it personally using MyFaces it was working gr8 but i had a hardtime on deploying my appln on a Portal Server(Liferay).If you find a workaround i'd be glad to know about it.
    & there are many BI Open Source Server Appls that can take care of this work too.(Maintainace wud be a tough ask when we go for this)
    For, the design perspective had i've been ur PM i wud have choose BI Server if it was corporate web appln on which we work on.
    Hope this might be of some help :)
    REGARDS,
    RaHuL

  • How to convert an Image to a byte array?

    I want to make a screenshot and then convert the image to a byte of arrays so I can send it through a BufferedOutputStream.
    try
                   robot = new Robot();
                   screenshot = robot.createScreenCapture(new Rectangle(500,500));
                   imageFile = new File("image.png");
                   ImageInputStream iis = ImageIO.createImageInputStream(screenshot);
                   byte[] data = new byte[1024];
                   byte[] tmp = new byte[0];
                   byte[] myArrayImage = new byte[0];
                   int len = 0;
                   int total = 0;
                   while((len = iis.read(data)) != -1 ) // LINE 52 --- EXCEPTION CATCHED HERE
                        total += len;
                        tmp = myArrayImage;
                        myArrayImage = new byte[total];
                        System.arraycopy(tmp,0,myArrayImage,0,tmp.length);
                        System.arraycopy(data,0,myArrayImage,tmp.length,len);
                   ios.close();I get this exception while running:
    Exception in thread "Thread-0" java.lang.NullPointerException
    at Server.run(Server.java:52)
    at java.lang.Thread.run(Unknown Source)

    Fixed that. I got a new problem.
    When I connect to my simple server application that reads the image file, converts it to an array of bytes and sends it back, the file is created on the client side and it containts data, but I am not able to open the image. I have checked that the image that the server is sending is working. So where is the problem?
    The client application recieves the image as following:
    public void run()
            try
                socket = new Socket("127.0.0.1", 2000);
                BufferedOutputStream out_file = new BufferedOutputStream(new FileOutputStream("recieved_img.png"));
                BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                int inputLine;
                while((inputLine = in.read()) != -1)
                    char c = (char)inputLine;
                    System.out.println(c);
                    out_file.write(inputLine);
            catch(IOException err){ err.printStackTrace(); }
        }And the server sends the image like this;
    try
              socket = server.accept();
              in=new BufferedReader(new InputStreamReader(socket.getInputStream()));
              out = new BufferedOutputStream(socket.getOutputStream());
              out.write(25);
              while((inputLine = in.readLine()) != null)
                   System.out.println(myArrayImage.length);
              System.out.println(inputLine);
                        out.write(myArrayImage);     // Send the array of bytes
         }

  • Displaying an html page from a byte array

    I'm trying to display an html page that i receive from a byte[ ] but the navigator asks me to download it instead of displaying it.

    exactly a better option here would be display that HTML content using a dedicated servlet/jsp.
    checkout below example code snippet hope that might help
    public void doPost(request,response)throws ServletException,IOException{
      //fetch HTML bytes.
      Byte buffer[] = Delegate.getBufferData(); 
      ByteArrayInputStream in = new ByteArrayInputStream(buffer);
      int contentSize = in.available();
      response.setContentType("text/html");
      response.setContentLength(contentSize);
      BufferedOutputStream out = null;
       try{
            out = new BufferedOutputStream(response.getOutputStream());
            while( contentSize-- >  0 )
                out.write(in.read());
             out.flush();
       }catch(Exception exp){
             exp.printStackTrace();
              throw new Exception(exp.getMessage());
       }finally{
              try{
                    if(out != null)
                       out.close();
                    if(in != null)
                        in.close();
              }catch(Exception ep){
                              ep.printStackTrace();
                              throw new Exception(ep.getMessage());
              }finally{
                    out = null;
                    in = null;
    }and respectively call the servlet.
    Hope this might help :)
    REGARDS,
    RaHuL

  • Converting Image.jpg to byte array

    Hi,
    How do i convert a image (in any format like .jpeg, .bmp, gif) into a byte array
    And also vice versa, converting byte array to image format
    Thank you

    how about Class.getResourceAsStream(String name).read(byte[] b)?

  • Color change when transferring image from Photoshop to After Effects

    Hi everyone,
    I am trying to import a logo from photoshop CS6 to After Effects CS6, however the black color within the image changes to a dark grey when it gets into AE. I noticed on the color picker in PS that it changes to the same grey color that is used as the replacement web safe color. Therefore I'm assuming AE is just converting everything into web safe colors.
    Is there something I need to change in AE to allow me to import the image and keep all the original non web safe photoshop colors?
    Sorry if this is a very basic question thats been answered before, I couldn't seem to find the answer within these forums.
    Many thanks in advance,
    Spencer

    This has nothing to do with web safe. You are making a mess of color management/ color profiles. You have soemthing enabled in PS and since AE by default doesn't use any color managemnt and just assumes plain sRGB, the colors change. There's no easy explanations here, but you have soem reading up to do about color management in general and also specifically how Photoshop corrects for monitor profiles and how to use the Proof Preview to compensate for that or how to establish a workflwo that mimicsa AE's "unmanaged" colorspace.
    Mylenium

Maybe you are looking for

  • Error: BeX-Web Application Error

    Hi All,                         while running the dashboard which is integrated with Enterprise portal, we are getting the below error.These dashboards consumes data from the BEX query  directly using the SAP Netweaver connection Type.   Error Desc:

  • Corruption in iPhoto

    Hi, I am having a problem viewing some of my older photos. I think that haste in uploading files that i later deleted haphazardly has led to corruption of my library. I can see the thumbnails, but cannot view these files (maybe 10% of all of the phot

  • Need instructions on how to get Quanser working with LabView 7.1

    I need information on what LabView modules or addins to install in order to run Quanser (QNET Experiments release 2.2).  LabView 7.1 is loaded but we also have LabView 7.0 if needed.

  • HP G62 455SX Hardware Upgrades

    Hi Hp , My labtop Possibilities is : Card name: Intel(R) HD Graphics Manufacturer: Intel Corporation Chip type: Intel(R) HD Graphics (Core i3) DAC type: Internal Device Key: Enum\PCI\VEN_8086&DEV_0046&SUBSYS_1425103C&REV_02 Display Memory: 762 MB And

  • Query for non turn customer report in service module(Add-on)

    Hi, I want create  query for non turn customer report, that mean the customer who are not come for  last 6 months to our service workshop in service module(Add-on). this is a scenario.    SELECT T1.U_CardDate, T1.U_JCardNo,T1.U_TypeSrv,T2.U_VehReg,T2