IOImage.write showing error after byte[] to BufferedImage

I am new to Image Manipulations in Java and I am writing some program related to Image Steganography by Mapping Pixels to Letters..
I have successfully read the data from gray scale image to BufferedImage object and read the pixels in byte array..
byte []data;
DataBufferByte buffer = (DataBufferByte) image.getRaster().getDataBuffer();
data = buffer.getData();Now for testing the working of my pixel morphing I have changed two pixels data[0] and data[1] and tried to store it in some target.jpg file.. For that I used
image.data[0]=(byte)3;
image.data[1]=(byte)1;
InputStream in = new ByteArrayInputStream(image.data);
    try {
            BufferedImage img = javax.imageio.ImageIO.read(in);
            image.write(img, ref);
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
Now I am getting error because ImageIO.read is returning NULL to BufferedImage img.. hence write method is throwing IllegalArgumentException.
I am totally lost.. please help me..
Edited by: Neo_Cerf on Feb 22, 2010 8:01 PM

Wrap the byte array in a DataBufferByte. Create an appropriate raster via one of the Raster#createXXXRaster methods. Then create and appropriate ColorModel and use the BufferedImage constructor that takes a raster and a color model. For a byte[] array representing gray data, this would be done like so.
byte[] imgData = ...;
int w = ...;
int h = ...;
//the DataBuffer
DataBuffer db = new DataBufferByte(imgData,imgData.length);
//the Raster
WritableRaster rast =  Raster.createInterleavedRaster(
       db, w, h, w, 1, new int[]{0}, null);
//the ColorModel
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
ColorModel cm = new ComponentColorModel(
       cs,new int[]{8}, false, true,
       java.awt.Transparency.OPAQUE,
       DataBuffer.TYPE_BYTE);
//the BufferedImage
BufferedImage img = new BufferedImage(cm,rast,true,null);

Similar Messages

  • How do I convert a large file which show error after is converting?

    I've tried to export a PDF to Excel and  word file and have not been able, show error after downloading and show converting in progress
    File is les 100MB and 936 pages

    Hi Large Files to Convert,
    Even when a PDF file is under the 100-MB file size limit, it could be that the large number of pages is adding a level of complexity that causes the ExportPDF service to timeout before it can finish the conversion.
    If the PDF file wasn't created from a scanned document, you can simplify the conversion somewhat by disabling OCR as described in this document: How to disable Optical Character Recognition (O... | Adobe Community
    Otherwise, you might want to consider using a free trial of Acrobat to convert that large file. For more information, see www.adobe.com/products/acrobat.html.
    Best,
    Sara

  • After assigning to g/l a/c determinationiit is showing error after update

    firstly I make a coa dtw.      Now why after assigning the accounts in the sales tab in G/L a/c deter mination get automatically get deleted .And also it is showing an error that Reconciliation account required[Periods category -Periods category Debitors follodo i have to be makew up account].kindly help what are the adjustmentsto be made.

    Hi Arijit
    The account determination is per period (year). Check that you have the correct fiscal year selected when updating the account determination. If you have created prior fiscal years, the best is to define the accounts in the oldest period first and make sure that all fiscal years are populated. When you add a new fiscal year in the future, the current year will automatically be copied to the new year's account determination. The reason for this is to allow customers to assign different accounts per fiscal year if needed. In most cases accounts do not change by year and should therefore remain the same.
    As for the reconciliation account, it is found under the General TAB of account determination and MUST be provided even if you don't think you will need it.
    Hope this helps.
    Kind regards
    Peter Juby

  • Install Oracle 8.1.6 (Solaris): show error after runInstaller

    Hello,
    After entered "runInstaller" on my SunOS 5.6, the following error message appeared
    "Initializing Java Virtual Machine from <.... a list of library ........> Please wait..."
    Error in CreateOUIProcess : 14
    :Bad Address
    I've already set ENVIRONMENT variables (including DISPLAY)
    csh> xhost +
    csh> setenv DISPLAY my_workstation_name:0.0
    Any suggestions?
    Thanks for your great help!!
    Kent

    You need to do the xhost +YOUR_MACHINE_NAME as root.                                                                                                                                                                                                           

  • WPC Content showing error after portal upgrade to 7.3

    Hi All,
         Recently we have upgraded our portal from 7.0 to 7.3.We have WPC contents on our portal its was fine till upgrade.After upgrade we are facing issues in all the WPC content.I reproduce the issue and checked the NWA log i could see the below logs.
    com.sapportals.portal.prt.runtime.PortalRuntimeException: There is no portal component associated with the following context: pcd:<PCD PATH OF THE IVIEW>
    So i thought of creating a new contents as mine was simple but when i navigate to the Web Page Composer ->Web site Management.I could see only the link not the content when i click.Below log i could see after this
    cannot find bundle file or key for resource type wpc_site_root, use fallback
    No mapping available for requested LayoutController with alias <WpcNavigationLayoutController>
    com.sapportals.wcm.WcmException: Error: Archiving Service isn't available
    at com.sapportals.wcm.rendering.uicommand.cm.UIAbstractApproveRejectArchivingCommand.setArchivingService(UIAbstractApproveRejectArchivingCommand.java:162)
    at com.sapportals.wcm.rendering.uicommand.cm.UIAbstractApproveRejectArchivingCommand.<init>(UIAbstractApproveRejectArchivingCommand.java:42)
    Kindly help me to solve the issue.
    Naga

    << Do not post the same question across a number of forums >>

  • MDT Offline Image or Media Showing Error after FInished

    Hello,
    Please help me I have MDT 2013 with Windows 2012 R2 and WDS I am using the MDT for Offline Image via USB.
    My Problem that MDT showing a lot of Error
    Failure ( 9601 ) Error - ZTITatoo State restore task should be running in the full OS, Aborting
    Failure ( 5496 ) : 1: LoadControlfile.findfile: Application.XML
    Lite touch deployment failed, Return code = -2147467259 0x80004005
    how I can solve it?
    I'm trying to deploy the offline image through usb without joining the domain and without network connectivity.
    Here below the Error Code
    Thanks  
    FZ2H

    Please check your applications.xml on your USB media. It is located in the Deploy\Control folder. Check if the file exists, is not corrupted and is not read only.
    The applications.xml holds all the installation commands for the applications which are used during installation.
    Since it can't find the xml file the installation aborts.
    The error is a bit curious since normally the automatic creation process of the offline media, embeds the entire .\control folder on your media iso. So normally it should be there, or you have done something that isn't yet mentioned here.
    Anyways, good luck!
    If this post is helpful please click "Mark for answer", thanks! Kind regards

  • Addisctl.sh showing errors

    Hi All,
    Whenever i try to run the applications the addisctl.sh script takes a lot of time and also show errors after execution.
    My Application version is : 11.5.9
    Database Version is: 9.2.0.3
    Os version is: RHEL 3
    The script result is:
    [applerpp@hertz applerpp]$start_applerpp
    You are running adstrtal.sh version 115.9
    Executing service control script:
    /erpp/erppcomn/admin/scripts/ERPP_hertz/adapcctl.sh start
    script returned:
    adapcctl.sh version 115.32
    Starting Apache Web Server Listener (dedicated HTTP) ...
    Starting Apache Web Server Listener (dedicated PLSQL) ...
    /erpp/erppora/iAS/Apache/Apache/bin/apachectl start: httpd started
    adapcctl.sh: exiting with status 0
    .end std out.
    Executing service control script:
    /erpp/erppcomn/admin/scripts/ERPP_hertz/adalnctl.sh start
    script returned:
    adalnctl.sh version
    Checking for FNDFS executable.
    Starting listener process APPS_ERPP.
    adalnctl.sh: exiting with status 0
    .end std out.
    Executing service control script:
    /erpp/erppcomn/admin/scripts/ERPP_hertz/adcmctl.sh start
    script returned:
    You are running adcmctl.sh version 115.16
    Starting concurrent manager for ERPP ...
    Starting ERPP_0801@ERPP Internal Concurrent Manager
    Default printer is noprint
    adcmctl.sh: exiting with status 0
    .end std out.
    Executing service control script:
    /erpp/erppcomn/admin/scripts/ERPP_hertz/adfrmctl.sh start
    script returned:
    You are running adfrmctl.sh version 115.26
    Starting forms server for ERPP on port 9000.
    adfrmctl.sh: exiting with status 0
    .end std out.
    Executing service control script:
    /erpp/erppcomn/admin/scripts/ERPP_hertz/adrepctl.sh start
    script returned:
    You are running adrepctl.sh version 115.15
    starting Reports Server for ERPP on port 7000.
    adrepctl.sh: exiting with status 0
    .end std out.
    Executing service control script:
    /erpp/erppcomn/admin/scripts/ERPP_hertz/adfmcctl.sh start
    script returned:
    You are running adfmcctl.sh version 115.15
    Starting forms load balancing client for ERPP.
    adfmcctl.sh: exiting with status 0
    .end std out.
    Executing service control script:
    /erpp/erppcomn/admin/scripts/ERPP_hertz/adfmsctl.sh start
    script returned:
    You are running adfmsctl.sh version 115.11
    starting forms metrics server for ERPP.
    adfmsctl.sh: exiting with status 0
    .end std out.
    Executing service control script:
    /erpp/erppcomn/admin/scripts/ERPP_hertz/jtffmctl.sh start
    script returned:
    You are running jtffmctl.sh version 115.7
    Starting Fulfillment Server for ERPP on port 9300 ...
    jtffmctl.sh: exiting with status 0
    .end std out.
    Executing service control script:
    /erpp/erppcomn/admin/scripts/ERPP_hertz/addisctl.sh start
    script returned:
    ERROR : Timed out: Interrupted Exception
    addisctl.sh version 115.8
    /erpp/erppora/8.0.6/vbroker/bin/osagent
    Waiting for OAD to start...
    Started OAD.
    OAD logs messages to the file /erpp/erppora/8.0.6/discwb4/util/oad.log.
    Discoverer Locator Started.
    Locator logs messages to the file /erpp/erppora/8.0.6/discwb4/util/locator.log.
    Cannot bind to OAD. Re-starting...
    OAD is stopped
    Unable to stop Osagent. No process-id file found.
    Locator is stopped
    Unable to stop gatekeeper. No process-id file found.
    No other discoverer processes running
    /erpp/erppora/8.0.6/vbroker/bin/osagent
    Waiting for OAD to start...
    Started OAD.
    OAD logs messages to the file /erpp/erppora/8.0.6/discwb4/util/oad.log.
    Discoverer Locator Started.
    Locator logs messages to the file /erpp/erppora/8.0.6/discwb4/util/locator.log.
    Registering Discoverer Session
    oadutil reg: Failed to bind to OAD
    Registering the Collector
    oadutil reg: Failed to bind to OAD
    addisctl.sh version 115.8
    /erpp/erppora/8.0.6/vbroker/bin/osagent
    Waiting for OAD to start...
    Started OAD.
    OAD logs messages to the file /erpp/erppora/8.0.6/discwb4/util/oad.log.
    Discoverer Locator Started.
    Locator logs messages to the file /erpp/erppora/8.0.6/discwb4/util/locator.log.
    Cannot bind to OAD. Re-starting...
    OAD is stopped
    Unable to stop Osagent. No process-id file found.
    Locator is stopped
    Unable to stop gatekeeper. No process-id file found.
    No other discoverer processes running
    /erpp/erppora/8.0.6/vbroker/bin/osagent
    Waiting for OAD to start...
    Started OAD.
    OAD logs messages to the file /erpp/erppora/8.0.6/discwb4/util/oad.log.
    Discoverer Locator Started.
    Locator logs messages to the file /erpp/erppora/8.0.6/discwb4/util/locator.log.
    Registering Discoverer Session
    oadutil reg: Failed to bind to OAD
    Registering the Collector
    oadutil reg: Failed to bind to OAD
    Command line may not be valid
    Exiting with status 1
    You have new mail in /var/spool/mail/applerpp
    [applerpp@hertz applerpp]$

    The LD_ASSUME_KERNEL is already set to the specified value and when i tried to run the addisctl script from the same session i got the same errors but when i run the checkdiscoverer.sh the ouput is:
    [applerpp@hertz util]$checkdiscoverer.sh
    Initializing ORB...
    ORB initialized successfully.
    Checking for OSAgent...
    java.lang.Exception: OSAgent Not Found
    Error: OSAgent is not running. Discoverer will not function correctly unless there is at least one OSAgent running in the subnet.
    Hint: Start OSAgent by running startosagent.sh under /erpp/erppora/8.0.6/discwb4/util.
    Checking for OAD...
    org.omg.CORBA.NO_IMPLEMENT[completed=MAYBE, reason=
      Could not locate the following object:
             repository id : IDL:visigenic.com/Activation/OAD:1.0
                 host name : 127.0.0.1
    Error: OAD is not running. Discoverer will not function correctly.
    Hint: Start OAD by running startoad.sh under /erpp/erppora/8.0.6/discwb4/util.
    Checking for Discoverer Locator...
    org.omg.CORBA.NO_IMPLEMENT[completed=MAYBE]
    Error: Discoverer Locator is not running. Clients outside the subnet will not be able to connect.
    Hint: Start Discoverer Locator by running startlocator.sh under /erpp/erppora/8.0.6/discwb4/util.
    Checking for Gatekeeper...
    WARNING: Attempting to use HTTP Firewall Proxy Server
    due to security restrictions: org.omg.CORBA.INTERNAL[completed=MAYBE, reason=Can not find GateKeeper: exception ReqFailure{}]
    org.omg.CORBA.INTERNAL[completed=MAYBE, reason=Can not find GateKeeper: exception ReqFailure{}]
    Error: Gatekeeper is not running. Clients outside the firewall will not be able to connect.
    Hint: Start Gatekeeper by running startgatekeeper.sh under /erpp/erppora/8.0.6/discwb4/util.
    Refer to the Discoverer Configuration Guide for more information on configuring Gatekeeper.
    Checking that the machine has only one network card...
    Yes.
    Pls help me on this issue
    Thanks and Regards
    Amit Raghuvanshi

  • Write file error 8

    Once the file is created subsequent writes show Error code 8 out of the "Write File" VI LV6. (Cannot upgrade the code at this time). I'm using open/create/Replace File VI along with the Write File VI. Creating the file run OK, once I go back and rerun for a write the "Write File" reports Error code 8. How do I fix this issue.... using LV6.

    The file created by the open/create/Replace VI attributes are NOT set to READ ONLY. See the pic below. If the LV creates the file it should be able to subsequently write to the same file. Once again this is LV version 6. It didn't work this way before... I took a look at a few things in the code and noticed this anomaly.
    BTW, there are root or branch level folder showing the Read Only attribute is inherited from parent folder... but my whole C drive is this way... but LV should be able to write to the file regardless....
    Message Edited by richjoh on 12-22-2009 03:53 PM

  • How to show error message next to the field?

    Hi All,
    I am writing my own form handler and I am trying to show form field errors without using errormessageforeach droplet for learning purpose.
    I am able to show to the fields errors but I want to show them next to the fields.
    How can i achieve this functionality?
    Regards,
    Prateek

    PrateekG wrote:
    Hi All,
    I am writing my own form handler and I am trying to show form field errors without using errormessageforeach droplet for learning purpose.
    I am able to show to the fields errors but I want to show them next to the fields.
    How can i achieve this functionality?
    Regards,
    Prateek
    You can use JQuery/JavaScript to validate for errors and div to show error after field like below:
    <dsp:input type="text"  bean="MyFormHandler.cashierId"  />
         <dsp:valueof bean="MyFormHandler.errorMap.firstname"/>
    <div id="firstNameError">Your error message will goes here<div>
    -RMishra

  • My ipod touch is stuck up at Apple Logo, I have tried to update and restore through ITunes but no use, It stuck up again at Apple Logo with no Error, after restoring it showes your ipod is restore but still apple logo won't go

    My ipod touch is stuck up at Apple Logo, I have tried to update and restore through ITunes but no use, It stuck up again at Apple Logo with no Error, after restoring ITunes  showes your ipod is restore but still apple logo won't go, Due to new Laptop, I do not have any backup, therefore i have tried to select new Ipod touch and goes through step by step procedure but no use, Please help what to do?

    i tried reseting my ipod today and had a similar problem... it wont be recognized by itunes, the only thing i havent tried is putting it into DFU mode, or the state that it is in when u recieve it telling u to connect it to itunes.i recommend putting it into DFU mode. http://www.youtube.com/watch?v=34v8HMC9B98 this should better explain it. if i find another way, ill keep u updated

  • Download error under apps. After following download steps multiple times still showing error message.

    Download error under apps. After following download steps multiple times still showing error message.

    Hi There,
    Kindly try the below mentioned links.
    Creative Cloud Help | Download Error in Apps tab of Creative Cloud Desktop Application
    Creative Cloud - Download error - stubborn error
    Thanks,
    Atul Saini

  • Install from SCSI CD fails: ERROR: boot device didn't show up after 30

    I have a x86 based server w/SCSI HD and DVD drive. 
    Install fails with following.
    Waiting 30 seconds for device /dev/disk/by-label/ARCH_201108
    ERROR: boot device didn't show up after 30 seconds
       Falling back to interactive prompt
       You can try to fix the problem manually, logout when you are finished
    sh: can't access tty; job contro turned off
    [ramfs /]#
    I hooked up a IDE DVD drive and using same CD installs OK.  Then, once installed, I switch my DVD back to SCSI that failed the install, and guess what?  Arch booted from my HD now recognizes the SCSI DVD drive, I can mount it and so on.  Looks to me like the install kernel doesn't support my SCSI DVD drive but the installed kernel does.
    I need the Arch install to work from the SCSI DVD drive on my system.  I'm trying to develop an Arch distro for my particular system, which there are about a dozen of in the field, they all have SCSI DVD and no IDE drives.  Will I have to add a SCSI driver to the boot kernel?  Or is my problem something else?
    I notice there is no /dev/disk/by-label (ther is a /dev/disk/by-id  by-label  and by-uuid).
    I do a:
    "[ramfs /]# lsmod | grep sr_mod"
    sr_mod        14951   0
    cdrom        36329   1   sr_mod
    scsi_mod    131482   7  sg,sr_mod,sd_mod,libata,mptspi,mptscsih,scsi_transport_spi
    [ramfs /]# lsmod | grep scsi
    mptscsih        20040   1   mptspi
    mptbase            63459    2   mptspi,pmtscsih
    scsi_transport_spi    20059   1   mptspi
    scsi_mod        131482  7   sg,sr_mod,sd_mod,libata,mptspi,mptscsih,scsi_stransport_spi

    scrath "I notice there is no /dev/disk/by-label (ther is a /dev/disk/by-id  by-label  and by-uuid)."
    Should be: I notice there is no /dev/disk/by-label (there is a /dev/disk/by-id  by-path  and by-uuid).

  • TS3694 pls help me guys ...i tried to update the new software update ios 7 but when i connected my iphone it took more then half hour to download but after it just shows me the icon on my iphone that connect ur iphone with itunes..it shows error(4005) hel

    i tried to upgrade to ios 7 but it shows error 4005...it took more then 45 mins to download but after it just shows an image on my iphone that connect ur phone with i tunes i tried it but there's nothing happening and now i cant even use my iphone....pls help me what to do????

    I have tried the steps to fix it but no solution! Please someone tell me what to do!

  • Pls/portal shows: Error: The portlet could not be contacted  after SSL enab

    The OCS /pls/portal page shows: Error: The portlet could not be contacted, I believe this happened after SSL enabling the system. Anyone out there seen this errof before?

    FYI
    This happens if you remove port 80 as a listening port webcache/em, etc. Oracle claims it needs port 80 for internal communication. For whatever reason the /pls/portal providers are registered in non-SSL. Not sure if Oracle will provide a fix or ?

  • I'm now at Sudan. I'm from Bangladesh. After coming Sudan I can't download/install any application from apps store. It shows error code-1009. Now what to do ? can anybody help me....?

    I'm now at Sudan. I'm from Bangladesh. After coming Sudan I can't download/install any application from apps store. It shows error code-1009. Now what to do ? can anybody help me....?

    Are you trying to download apps from the Sudan app store?  If so, you have to have a valid credit card and billing address in the country of the app store to purchase from that app store.
    Some countries also have restrictions on the apps and functions allowed in their countries.

Maybe you are looking for

  • Tasks display fine in iCal, but not in Mail

    In iCal I have my task list on the right which is showing all my tasks just fine. However, in Mail I have an IMAP account with a Apple Mail To Do folder instead of a special entry in the source list for tasks. I used to have a special entry for that,

  • How can I revert to a backup for my icloud account?

    I bought my wife a new IMac which works great.  The problem is that icloud pushed all my phone contacts to her imac after I signed on to my iphone/istore account using her imac.  I deleted all the contacts from her imac (bad move) which in turn delet

  • Suggestion on how to make this photo better

    It is a timelapse of stars, the sky was seperated from the forground so I could edit the forground better.  But I feel like something does not match up right.  Possible the white balance is different with the background and forground.  Not sure so ne

  • Hp4050tn connection through airport problems

    Printer:  HP4050TN Computer:  iMac 27" (2010) w/ OS 10.6.8 Wireless Router:  Airport Extreme Connection:  Ethernet RJ45 printer to Airport Problem:  I have had this configuration since 5/2010, and a week ago for some reason the iMac would not connect

  • ACS Database Replication over VPN with overlapping Network Addresses

    We currently have two co-locations each situated in different provinces. We have two ACS servers which we want to deploy at each co-location. All our network equipments are behind PIX/ASA devices. Getting them to replicate over the VPN should be easy