Buggy code:
int oldMemBitmap = OS . SelectObject ( memHdc , memDib ) ; BITMAP dibBM = new BITMAP ( ) ; OS . GetObject ( memDib , sizeof , dibBM ) ; int sizeInBytes = ( dibBM . bmWidthBytes ) * ( dibBM . bmHeight ) ; OS . BitBlt ( memHdc , 0 , 0 , imgWidth , imgHeight , srcHdc , 0 , 0 , SRCCOPY ) ; byte red = 0 ; byte green = 0 ; byte blue = 0 ; if ( transparentPixel != ( - 1 ) ) { if ( ( bm . bmBitsPixel ) <= 8 ) { byte [ ] color = new byte [ 4 ] ; OS . GetDIBColorTable ( srcHdc , transparentPixel , 1 , color ) ; blue = color [ 0 ] ; green = color [ 1 ] ; red = color [ 2 ] ; } else { switch ( bm . bmBitsPixel ) { case 16 : blue = ( ( byte ) ( ( transparentPixel & 31 ) << 3 ) ) ; green = ( ( byte ) ( ( transparentPixel & 992 ) > > 2 ) ) ; red = ( ( byte ) ( ( transparentPixel & 31744 ) > > 7 ) ) ; break ; case 24 : blue = ( ( byte ) ( ( transparentPixel & 16711680 ) > > 16 ) ) ; green = ( ( byte ) ( ( transparentPixel & 65280 ) > > 8 ) ) ; red = ( ( byte ) ( transparentPixel & 255 ) ) ; break ; case 32 : blue = ( ( byte ) ( ( transparentPixel & - 16777216 ) > > > 24 ) ) ; green = ( ( byte ) ( ( transparentPixel & 16711680 ) > > 16 ) ) ; red = ( ( byte ) ( ( transparentPixel & 65280 ) > > 8 ) ) ; break ; } } } byte [ ] srcData = new byte [ sizeInBytes ] ; OS . MoveMemory ( srcData , pBits [ 0 ] , sizeInBytes ) ; if ( hMask != 0 ) { OS . SelectObject ( srcHdc , hMask ) ; for ( int y = 0 , dp = 0 ; y < imgHeight ; ++ y ) { for ( int x = 0 ; x < imgWidth ; ++ x ) { if ( ( OS . GetPixel ( srcHdc , x , y ) ) != 0 ) { srcData [ ( dp + 3 ) ] = ( ( byte ) ( 0 ) ) ; } else { srcData [ ( dp + 3 ) ] = ( ( byte ) ( 255 ) ) ; } dp += 4 ; } } } else if ( alpha != ( - 1 ) ) { for ( int y = 0 , dp = 0 ; y < imgHeight ; ++ y ) { for ( int x = 0 ; x < imgWidth ; ++ x ) { srcData [ ( dp + 3 ) ] = ( ( byte ) ( alpha ) ) ; dp += 4 ; } } } else if ( alphaData != null ) { for ( int y = 0 , dp = 0 , ap = 0 ; y < imgHeight ; ++ y ) { for ( int x = 0 ; x < imgWidth ; ++ x ) { srcData [ ( dp + 3 ) ] = alphaData [ ( ap ++ ) ] ; dp += 4 ; } } } else if ( transparentPixel != ( - 1 ) ) { for ( int y = 0 , dp = 0 ; y < imgHeight ; ++ y ) { for ( int x = 0 ; x < imgWidth ; ++ x ) { if ( ( ( ( srcData [ dp ] ) == blue ) && ( ( srcData [ ( dp + 1 ) ] ) == green ) ) && ( ( srcData [ ( dp + 2 ) ] ) == red ) ) { <START_BUG> srcData [ ( dp + 3 ) ] = ( ( byte ) ( 0 ) ) ; <END_BUG> } else { srcData [ ( dp + 3 ) ] = ( ( byte ) ( 255 ) ) ; } dp += 4 ; } } } else { for ( int y = 0 , dp = 0 ; y < imgHeight ; ++ y ) { for ( int x = 0 ; x < imgWidth ; ++ x ) { srcData [ ( dp + 3 ) ] = ( ( byte ) ( 255 ) ) ; dp += 4 ; } } } OS . MoveMemory ( pBits [ 0 ] , srcData , sizeInBytes ) ; OS . SelectObject ( srcHdc , oldSrcBitmap ) ; OS . SelectObject ( memHdc , oldMemBitmap ) ; OS . DeleteObject ( srcHdc ) ; OS . DeleteObject ( memHdc ) ; OS . ReleaseDC ( 0 , hDC ) ; if ( ( hBitmap != ( image . handle ) ) && ( hBitmap != 0 ) ) OS . DeleteObject ( hBitmap ) ; if ( hMask != 0 ) OS . DeleteObject ( hMask ) ; return memDib ; } static int create32bitDIB ( int hBitmap , int alpha , byte [ ] alphaData , int transparentPixel ) { } static Image createIcon ( Image image ) { } static int createMaskFromAlpha ( ImageData data , int destWidth , int destHeight ) { } static synchronized void deregister ( Display display ) { } protected void destroy ( ) { } void destroyDisplay ( ) { } public void disposeExec ( Runnable runnable ) { }

Fix:
srcData [ ( dp + 0 ) ] = srcData [ ( dp + 1 ) ] = srcData [ ( dp + 2 ) ] = srcData [ ( dp + 3 ) ] = ( ( byte ) ( 0 ) ) ;