Buggy code:
totalWidth += hdItem . cxy ; } if ( totalWidth > ( ( clientRect . right ) - ( clientRect . left ) ) ) { pRect . left = 0 ; pRect . right = totalWidth ; } else { pRect . left = clientRect . left ; pRect . right = clientRect . right ; } if ( index == ( count - 1 ) ) backgroundRect . right = pRect . right ; } int hTheme = OS . OpenThemeData ( handle , TREEVIEW ) ; int iStateId = ( selected ) ? OS . TREIS_SELECTED : OS . TREIS_HOT ; if ( ( ( OS . GetFocus ( ) ) != ( handle ) ) && selected ) iStateId = OS . TREIS_SELECTEDNOTFOCUS ; OS . DrawThemeBackground ( hTheme , hDC , TVP_TREEITEM , iStateId , pRect , backgroundRect ) ; OS . CloseThemeData ( hTheme ) ; } } } else { if ( selected ) { selectionForeground = newTextClr ; if ( ! ( explorerTheme ) ) { if ( ( clrTextBk == ( - 1 ) ) && ( OS . IsWindowEnabled ( handle ) ) ) { Control control = findBackgroundControl ( ) ; if ( control == null ) control = this ; clrTextBk = control . getBackgroundPixel ( ) ; } } } } } } if ( ( selectionForeground ) != ( - 1 ) ) clrText = selectionForeground ; } if ( ! ( ignoreDrawBackground ) ) { if ( clrTextBk != ( - 1 ) ) { if ( drawBackground ) fillBackground ( hDC , clrTextBk , backgroundRect ) ; } else { Control control = findImageControl ( ) ; if ( control != null ) { if ( i == 0 ) { int right = Math . min ( rect . right , width ) ; OS . SetRect ( rect , rect . left , rect . top , right , rect . bottom ) ; if ( drawBackground ) fillImageBackground ( hDC , control , rect ) ; } else { if ( drawBackground ) fillImageBackground ( hDC , control , rect ) ; } } } } rect . left += ( Tree . INSET ) - 1 ; if ( drawImage ) { Image image = null ; if ( index == 0 ) { image = item . image ; } else { Image [ ] images = item . images ; if ( images != null ) image = images [ index ] ; } int inset = ( i != 0 ) ? Tree . INSET : 0 ; int offset = ( i != 0 ) ? Tree . INSET : ( Tree . INSET ) + 2 ; if ( image != null ) { Rectangle bounds = image . getBounds ( ) ; if ( size == null ) size = getImageSize ( ) ; int y = rect . top ; if ( ! ( ignoreDrawForeground ) ) { GCData data = new GCData ( ) ; data . device = display ; GC gc = GC . win32_new ( hDC , data ) ; <START_BUG> gc . drawImage ( image , 0 , 0 , bounds . width , bounds . height , rect . left , y , size . x , size . y ) ; <END_BUG> gc . dispose ( ) ; } OS . SetRect ( rect , ( ( ( rect . left ) + ( size . x ) ) + offset ) , rect . top , ( ( rect . right ) - inset ) , rect . bottom ) ; } else { if ( i == 0 ) { if ( ( OS . SendMessage ( handle , TVM_GETIMAGELIST , TVSIL_NORMAL , 0 ) ) != 0 ) { if ( size == null ) size = getImageSize ( ) ; rect . left = Math . min ( ( ( rect . left ) + ( size . x ) ) , rect . right ) ; } } else { OS . SetRect ( rect , ( ( rect . left ) + offset ) , rect . top , ( ( rect . right ) - inset ) , rect . bottom ) ; } } } if ( drawText ) { if ( ( rect . left ) < ( rect . right ) ) { String string = null ; if ( index == 0 ) { string = item . text ; } else { String [ ] strings = item . strings ; if ( strings != null ) string = strings [ index ] ; } if ( string != null ) { if ( hFont != ( - 1 ) ) hFont = OS . SelectObject ( hDC , hFont ) ; if ( clrText != ( - 1 ) ) clrText = OS . SetTextColor ( hDC , clrText ) ; if ( clrTextBk != ( - 1 ) ) clrTextBk = OS . SetBkColor ( hDC , clrTextBk ) ; int flags = ( ( OS . DT_NOPREFIX ) | ( OS . DT_SINGLELINE ) ) | ( OS . DT_VCENTER ) ; if ( i != 0 ) flags |= OS . DT_ENDELLIPSIS ; TreeColumn column = ( ( columns ) != null ) ? columns [ index ] : null ; if ( column != null ) { if ( ( ( column . style ) & ( SWT . CENTER ) ) != 0 ) flags |= OS . DT_CENTER ; if ( ( ( column . style ) & ( SWT . RIGHT ) ) != 0 ) flags |= OS . DT_RIGHT ; } TCHAR buffer = new TCHAR ( getCodePage ( ) , string , false ) ;

Fix:
gc . drawImage ( image , 0 , 0 , bounds . width , bounds . height , ( ( ( rect . left ) - inset ) + 1 ) , y , size . x , size . y ) ;