Dithering no longer works under 1.4.2

I had this posted in the AWT forum and I was suggested that the issue was better suited to the Java 2D forum:
I am trying to convert a jpeg to a 1 bit per pixel Buffered image.
The current implementation is working fine under 1.3.1_05 but not under any of the 1.4.2 JVM's that I have tried. Any tips on what I am doing wrong?
Here is a snippet of the the code:
// input stream is from a jpeg file:
JPEGImageDecoder jpgDecoder = JPEGCodec.createJPEGDecoder(src);
// decompress to a AWT buffered image. this will be our source image in the color
// space of the original jpg.
BufferedImage srcImg = jpgDecoder.decodeAsBufferedImage();
// create an output buffered image in the color space that we need. in this case
// one bit binary.
BufferedImage destImage =null;
Graphics2D graphics=null;
int bufferedImageType = BufferedImage.TYPE_BYTE_BINARY;
// cols and rows are passed in as parameters
destImage = new BufferedImage(cols,rows,bufferedImageType);
// create a Graphics2D context out of the Output buffered image and draw the
// source image to it. This will convert the color space for us. At least it does under 1.3.1
graphics=destImage.createGraphics();
// the following commented line has the effect of inverting the color for us.
// this would be nice except it seems to have the effect of hanging 1.3.1 JVM.
//graphics.setXORMode(Color.WHITE);
graphics.drawImage(srcImg,null,0,0);
// get the data buffer from the destImage and send it back to the caller
DataBufferByte dataBuffer = (DataBufferByte)destImage.getData().getDataBuffer();
return dataBuffer;
This works great under 1.3.1 The returned data buffer is merged with some other images and the result is a nicely dithered 1 bpp output image. (I am currently generating either tiff or png at 1bpp).
Under 1.4.2 it seems that instead of dithering I get some sort of thresholding that looks awfull. No attempt to emulate grayscale is made at all.
Has anyone encounterd this problem? I have looked through the forum but nothing similar seems to be posted.
If you need a more concrete example I can post a main that reads the jpg, converts it to 1bpp and saves it as a tiff.
Thanks
Richard Seabright.

Here is a sample class that demonstrates the issue (behaves differently under 1.4.2 than it does under 1.3.1):
import java.awt.*;
import java.awt.color.*;
import java.awt.image.*;
import javax.swing.*;
public class ColorConvert {
public static void main(String[] args) {
BufferedImage image0 = createSample();
BufferedImage image1 = convert(image0);
display(image0, image1);
public static BufferedImage createSample() {
BufferedImage result = new BufferedImage(450, 150, BufferedImage.TYPE_INT_RGB);
Graphics2D g = result.createGraphics();
g.setPaint(Color.yellow);
g.fillOval(10, 25, 100, 100);
g.setPaint(Color.red);
g.fillOval(80, 25, 100, 100);
g.setPaint(Color.green);
g.fillOval(150, 25, 100, 100);
g.setPaint(Color.blue);
g.fillOval(220, 25, 100, 100);
g.dispose();
return result;
public static BufferedImage convert(BufferedImage image) {
int w = image.getWidth(), h = image.getHeight();
BufferedImage result = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_BINARY);
Graphics2D g = result.createGraphics();
g.drawImage(image, null, 0, 0);
g.dispose();
return result;
public static void display(BufferedImage image0, BufferedImage image1) {
JPanel panel = new JPanel(new GridLayout(0,1));
panel.add(createLabel(image0));
panel.add(createLabel(image1));
JFrame f = new JFrame("ColorConvert");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setContentPane(panel);
f.pack();
f.setVisible(true);
public static JLabel createLabel(BufferedImage image) {
JLabel label = new JLabel(new ImageIcon(image));
label.setOpaque(true);
label.setBackground(Color.white);
label.setBorder(BorderFactory.createEtchedBorder());
return label;
}

Similar Messages

  • "Older" apps no longer work under 10.7

    Filemaker pro 7, Toast and Photoshop CS3 no longer work under 10.7. Is there any way to make these work or will I have to go back to OS 10.6?

    Time for an update.
    I'd scrap Toast.  And CS 5.5 and FileMaker Pro 11 are way better than the older versions you have, and will run substantially faster as native applicaitons.
    Though I thought CS3 was actually a Universal application and thus _should_ run on Lion (albeit not supported any more)

  • XITEL HiFi-Link AN1 No Longer Working Under 10.4.6

    My XITEL HiFi-Link is no longer working under 10.4.6.
    This USB sound device is selected as my output device.
    I have tried both USB ports - no sound.
    Both USB ports function properly with other input devices.
    Any Ideas?

    Kernel 3.13.7 contains the patch to fix this bug, from here on the mailing list: https://lkml.org/lkml/2014/3/20/819
    So now I don't have to hold back my kernel anymore, and this issue is resolved. Woopee!
    Last edited by zanny (2014-03-27 02:03:59)

  • ITunes Home Sharing No Longer Working Under Lion

    Home Sharing is no longer working between Lion and my Apple TV or iPhone. I am able to watch Netflix through my Apple TV (2nd Gen) so I do have connectivity. I have restarted both devices, and updated iTunes to 10.4. Under "Advanced" in iTunes, Home Sharing is turned on. In Preferences in iTunes under Sharing, it says Status: On, no users connected, even though my Apple TV is connected to the network.
    Is this problem isolated, or are others experiencing the same issue?

    I'm up and running. Spoke with Apple and they had me go to : preferences, network and create a new location. That seems to have reset something. I had to reset all my devices back to my main network that had stopped working. The guest network will not let Home Sharing work, only the main network.
    Others have been able to use Home Sharing without clicking "Done" after typing in their password. After you click "Done" the Shared disappears in iTunes.
    Apple help people were GREAT!

  • Sync no longer working under 10.6.3

    I can no longer sync under 10.6..3 to MobileMe, it worked perfectly prior to the update. When I open my address book I get the following pop up box stating:
    You need to replace your Contact Information on MobileMe. There is a box to click on that says "Replace". When I click on the box nothing happens.
    I went to the preferences pane and selected MobileMe-Sync-Advanced and invoked Reset Sync Data. That also did not work. I went to MobileMe using Safari and deleted all my contacts and tried everything again and nothing worked again. So I am stuck and unable to upload or sync from my computer to MobileMe. Incidentally, I also tried to run all the scripts using Cocktail and cleared all the caches. Any more ideas for me?

    direwolf8 wrote:
    I can't find anything in the specs that indicates this model is supported for Macintosh.
    as said worked fine under 10.5 and 10.4 on differtn Mac machines.
    a firmware upgrade from LG.
    can only be done under Windooz, correct? or can you do this on a Mac?
    Have you tried it with USB just to verify whether or not it works that way?
    just did, USB option works.

  • DVD Burner; LG  Super Multi DVD Rewriter no longer working under 10.6

    Model GSA-5163D, FireWire Burner.
    Since upgrading to 10.6 my computer no longer sees this burner.
    Any ideas as to how to get it to work under 10.6?
    Thanks

    direwolf8 wrote:
    I can't find anything in the specs that indicates this model is supported for Macintosh.
    as said worked fine under 10.5 and 10.4 on differtn Mac machines.
    a firmware upgrade from LG.
    can only be done under Windooz, correct? or can you do this on a Mac?
    Have you tried it with USB just to verify whether or not it works that way?
    just did, USB option works.

  • GPIB-ENET driver 1.10 no longer works under Windows 2000 service pack 2

    I have used my GPIB-ENET adapters with Windows 2000. However, since I installed service pack 2, the GPIB driver 1.10 no longer works. It seems to install correctly and puts the GPIB icon in the Control Panel. After a reboot, however, the icon is gone from the control panel ! It is even gone from the install/remove programs box. I have tried this on two PC's with the same result. This is really bad as my GPIB-ENET boxes are now useless. Can you help with this?

    Thanks for the advice, but the 1.20 drivers cannot be downloaded. They must be purchased for $80 US. I have already paid many thousands of dollars for three GPIB-ENET adapters plus LabVIEW. This is really shabby. I know of no other company that charges for driver updates once you have bought the hardware. I should have bought the Tektronix adapters instead.

  • Script no longer working under Maverick

    I just upgraded to Maverick over the weekend and I can not figure out why this script no longer works.  It has been working for the last 5 years.
    The script moves a file my server sends per e-mail to a folder on a partition on my Mac.  Here is the script.
    tell application "Microsoft Outlook"
              set selectedMsg to (current messages)
              set selectedMsg to item 1 of result
              set msgAttachment to attachments of selectedMsg
              set msgAttachment to result's item 1
              set attachmentName to name of msgAttachment
              set attachmentFile to ((path to desktop) & attachmentName) as text
      save msgAttachment in attachmentFile
    end tell
    delay 3
    set submitfolder to "OS E:Users:e:Desktop:" as alias
    set collectionfolder to "/Volumes/Data E/Consulting/Telephone Switch Record/2014" as alias
    tell application "Finder" to move (every file whose name contains ("week ") & (do shell script "date +%U")) to collectionfolder
    delay 2
    tell application "Finder" to move (every file whose name contains ("week ") & (do shell script "date +%U")) to trash
    I now get:
    If I run:
    tell application "Finder"
              open ("/Volumes/Data E/Consulting/Telephone Switch Record/2014" as POSIX file)
    end tell
    it opens the folder no problem so the path must be ok?  or? 
    Any ideas why it is broken? 

    Are you getting the error on this statement
    set collectionfolder to "/Volumes/Data E/Consulting/Telephone Switch Record/2014" as alias
    or when you do the move? And what is the error number you are getting?
    Also try this
    set filePart to "week " & (do shell script "date +%U")
    log filePart
    tell application "Finder" to move (every file whose name contains filePart) to collectionfolder
    to see what the string looks like.

  • File sharing no longer working under Lion

    File Sharing no longer works on our household macs running Lion. Shared volumes show up intermittedly in the finder sidebar. But connections fail.

    for what it's worth, i too am experiencing this issue and it is driving me insane... Any chance you two came across a workaround or fix?
    i've discovered that clicking on "AirDrop" on the shared Mac seems to awaken the shared services (screen sharing, file sharing etc.) and make them available on networked devices.
    i'm beginning to suspect that Bonjour may be the culprit as services advertised using Bonjour suddenly spring to life.
    it's short-lived unfortunately as availability eventually ceases... Clicking again on AirDrop reliably brings it back...
    That's where I am currently... if anybody has any ideas, I'd love to hear them.

  • Which extensions no longer work under 3.6.6 ?

    I hesitate to upgrade to 3.6.6 because whenever I upgrade some extension gets clobbered.
    Mozilla gives no hint about which extensions won't work under a new release, so I'm loath to upgrade.
    Is there a list somewhere of extensions clobbered or not by 3.6.6?

    The problem here is that Firefox does not develop the addons. Most addons are developed by outside people and therefore we don't support them. I would upgrade to 3.6.6 and by now most addons should be up to date and if there not give it a week or two. Note all the addons I use all work with the latest version of Firefox.

  • Automator workflow no longer working under Leopard

    Here's what I had - I use the Sonos music system which has a limit on total metadata. The longer the file path the more data was used. Therefore the folder system set up by iTunes (which I could not get rid of no matter what I tried) would end up using a lot of the data limit.
    I created an Automator task that did the following:
    1. Looked through my iTunes Music folder (on an external hard drive) for any folders.
    2. Took the contents of the folders and moved them to the iTunes Music folder.
    3. Searched through the iTunes Music folder for the now-empty subfolders
    4. Moved these empty subfolders to the trash.
    Using Leopard's Automator, I tried running my old workflow and got several error messages. Worse, it appears to have deleted my old workflow (can't find it anywhere) - whether or not Automator deleted it or I did accidentally, I no longer have it.
    Trying to replicate the old flow, I simply cannot put together instructions that work. I can't seem to empty the folders out, so that the folders in the trash are filled with the songs. Once I even accidentally moved the whole iTunes folder into the trash. I can't get the last "move to trash" command to work without an error message though it seems to actually work no matter that there's an error message.
    This shouldn't be too hard, but maybe I'm forgetting something simple. Anyone have any ideas?
    Thanks,
    Stu

    Adam,
    Numbers 3 should be free if you had it on your machine before (you were using Numbers 3 before, right?).  In App Store you might try clicking 'Account' under Quick Links and Reset all warnings for buying and downloading. And, if necessary, also contact Apple to get that charge reversed.
    I can't reproduce the script problem here. The fact that the Paste and Match Style is greyed seems to suggest that your copy of Numbers thinks there is nothing in the clipboard... Are you sure you don't have one of the many clipboard enhancement type applications on your machine?
    To test that you could try manually copying text into the clipboard (from say, TextEdit) and check to see if Numbers accepts a paste.
    Another thing to try: run the script from AppleScript Editor to see if you get the expected results from there.
    And also try this:  Open Terminal and at the ~ prompt type this command:
        date +%H:%M
    It should respond immediately with the time in 24-hour format.
    If you do get the time as expeced and you can't the the original script to work again,  then try the script below, which avoids the clipboard.
    SG
    tell application "Numbers"
              set t to front document's active sheet's first table whose selection range's class is range
              tell first cell of t's selection range
                        set value to do shell script "date +%H:%M"
              end tell
    end tell

  • Gmail app in wildblue home page no longer works under 4.0

    here is the source code:
    <Module><ModulePrefs title="__MSG_gmail_title__" author="__MSG_google_eng__" author_email="[email protected]" author_affiliation="Google Inc." author_location="Mountain View, CA" category="communication" category2="tools" description="__MSG_gmail_description__" screenshot="__MSG_gmail_screenshot__" thumbnail="__MSG_gmail_thm__"><Locale messages="builtin_content/en_ALL.xml"/><Locale lang="ar" messages="builtin_content/ar_ALL.xml" language_direction="rtl"/><Locale lang="bg" messages="builtin_content/bg_ALL.xml"/><Locale lang="ca" messages="builtin_content/ca_ALL.xml"/><Locale lang="cs" messages="builtin_content/cs_ALL.xml"/><Locale lang="da" messages="builtin_content/da_ALL.xml"/><Locale lang="de" messages="builtin_content/de_ALL.xml"/><Locale lang="el" messages="builtin_content/el_ALL.xml"/><Locale lang="en" messages="builtin_content/en_ALL.xml"/><Locale lang="en" country="uk" messages="builtin_content/en_uk.xml"/><Locale lang="en" country="de" messages="builtin_content/en_de.xml"/><Locale lang="es" messages="builtin_content/es_ALL.xml"/><Locale lang="et" messages="builtin_content/et_ALL.xml"/><Locale lang="fi" messages="builtin_content/fi_ALL.xml"/><Locale lang="fr" messages="builtin_content/fr_ALL.xml"/><Locale lang="he" messages="builtin_content/iw_ALL.xml" language_direction="rtl"/><Locale lang="hi" messages="builtin_content/hi_ALL.xml"/><Locale lang="hr" messages="builtin_content/hr_ALL.xml"/><Locale lang="hu" messages="builtin_content/hu_ALL.xml"/><Locale lang="hy" messages="builtin_content/hy_ALL.xml"/><Locale lang="id" messages="builtin_content/id_ALL.xml"/><Locale lang="is" messages="builtin_content/is_ALL.xml"/><Locale lang="it" messages="builtin_content/it_ALL.xml"/><Locale lang="iw" messages="builtin_content/iw_ALL.xml" language_direction="rtl"/><Locale lang="ja" messages="builtin_content/ja_ALL.xml"/><Locale lang="ko" messages="builtin_content/ko_ALL.xml"/><Locale lang="lt" messages="builtin_content/lt_ALL.xml"/><Locale lang="lv" messages="builtin_content/lv_ALL.xml"/><Locale lang="ms" messages="builtin_content/ms_ALL.xml"/><Locale lang="nl" messages="builtin_content/nl_ALL.xml"/><Locale lang="pl" messages="builtin_content/pl_ALL.xml"/><Locale lang="pt-br" messages="builtin_content/pt-br_ALL.xml"/><Locale lang="pt-pt" messages="builtin_content/pt-pt_ALL.xml"/><Locale lang="ro" messages="builtin_content/ro_ALL.xml"/><Locale lang="ru" messages="builtin_content/ru_ALL.xml"/><Locale lang="sk" messages="builtin_content/sk_ALL.xml"/><Locale lang="sl" messages="builtin_content/sl_ALL.xml"/><Locale lang="sr" messages="builtin_content/sr_ALL.xml"/><Locale lang="sv" messages="builtin_content/sv_ALL.xml"/><Locale lang="th" messages="builtin_content/th_ALL.xml"/><Locale lang="tl" messages="builtin_content/tl_ALL.xml"/><Locale lang="tr" messages="builtin_content/tr_ALL.xml"/><Locale lang="uk" messages="builtin_content/uk_ALL.xml"/><Locale lang="vi" messages="builtin_content/vi_ALL.xml"/><Locale lang="zh-cn" messages="builtin_content/zh-cn_ALL.xml"/><Locale lang="zh-tw" messages="builtin_content/zh-tw_ALL.xml"/></ModulePrefs><Content type="html">
    this is a builtin module, so the UserPrefs and Content are ignored.
    </Content></Module>
    under the 3.xxx versions i have on other units it works.
    Also the back and forward buttons no longer have the history down arrow to jump back to a previous page and is missed. version used is 4.01 on xp pro sp3

    well, try if anything in the following support articles (unless already consulted) helps:
    _*iTunes: Troubleshooting Home Sharing*_
    [_*Troubleshooting security software issues*_|http://support.apple.com/kb/TS3125]
    [_*Troubleshooting Home Sharing with Apple TV (2nd generation)*_|http://support.apple.com/kb/TS3509]
    good luck !
    JGG

  • ITunes auto sync no longer works under Lion

    SInce I upgraded to Lion, iTunes no longer automatically starts and syncs when I connect my iPhone or iPad.
    I checked the preferences:  both have the "start iTunes" automatically box checked.
    This is also the newest edition of iTunes:  10.4

    The fix involves iTunes helper.
    Go to login items and delete the one that's there.
    Then drag a new version of iTunes helper from the iTunes package to login items.
    I'm finding the transition to Lion more problematic than normal. Apple did not do a particularly good job of working the bugs out of this version of Mac os.

  • Apple remote no longer works under 10.6.2 on Mac Mini

    Have just updated my Mac Mini to 10.6.2, only to find that it no longer recognises the white Apple remote at all. I have tried both a paired remote and an unpaired remote. I have even tried pairing the unpaired remote. Nothing works. The Mini simply does not recognise it.
    This is really annoying as the Mac Mini is used as a media centre, and the remote is therefore used all the time through Front Row.
    Anyone else got this problem and, if so, is there a solution? Thank you so much.

    Candelair sadly didn't survive a restart on the Mac Mini, so I am back to not having any use of the Apple Remote whatsoever. Candelair had also caused some sound problems - the sound kept increasing and then decreasing.
    I am not sure what Apple added into the mix with 10.6.2 but it is a real pain! When you use a Mac Mini as a media centre, you need the use of a remote. And no sound problems.
    I am going to have to bite the bullet and spend hours today rolling back the Mini to 10.6 and then updating to 10.6.1 only if I can. 10.6.1 worked perfectly with the Apple Remote with just the Apple IR software.

  • Links in email no longer working under Yosemite

    I have several email signatures which contain icons that link to websites, etc. However, since upgrading to Yosemite these links no longer function. I can use command-k to add/edit/remove the link, but they do not work. Can anyone make any suggestions?

    If the iPad will not accept any input at all - try a reset. If this only occurs in the Xfinity email - something else is going on.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

Maybe you are looking for

  • Doubt while importing idoc (file 2 idoc scenario)

    hi, In IR, Imported objects..>Idocs while importing idoc there are two options to import according to software componet version, Overwrite sever info temporarily which one i have to use ? what circumstances i have to each option?

  • The app arrangement  pane is blank

    Just recently I have encountered issues when synching my iPhone and iPad. On the apps page, I have the list of apps that I can install but the layout pane where I should be able to arrange the apps is blank: I'm running Windows 7 with iTunes 11.1.5.5

  • Download speed for MAC

    Hi, I have MAc which is upgraded to OS lion. Strangely download speed on system is very less. for a small 22mb file its taking close to 3 hours. Any suggestions. Thanks dhargv

  • 11g on SLES 10 x86_64 problem

    Hi I'm trying to install Oracle 11g Database (linux.x64_11gR1_database.zip) on SLES 10 x86_64 SP1 (2.6.16.46-0.12-smp) And I've got error while linking: Exception Name: MakefileException Exception String: Error in invoking target 'ioracle client_shar

  • When taking a full data backup

    We take a full data backup of our LiveCache instance daily. My question is when you take a full backup (and it is successful) are any of the logs that are generated prior to the full backup needed any longer. My guess is no. But I would like to make