2015-07-03 21 views
-1

我使用HTMLEditorKit編寫了將圖像加載到JEditorPane中的代碼。我知道如何使用HTML來調整圖片的大小。但問題是加載的圖像質量下降。我正在設法調整大小而不會丟失質量。如何使用HTMLEditorKit將圖像加載到JEditorPane中同時順利調整大小?

+0

也許像[this](http://stackoverflow.com/a/4216635/230513)? – trashgod

+0

那麼,我使用htmlEditorKit的insertHTML()方法。我需要JEditorPane顯示的圖像,以便我可以調整它。但我找不到如何。 – Rahul

+0

將圖像加載到BufferedImage中,然後在linkby垃圾內容中調整大小,然後將其放到htmlEditorkit中 – Madhan

回答

0

作爲安德魯湯普森建議,

延長HTMLEditorKit並重寫的HTMLFactorypublic View create(Element element)

ImageView延伸並覆蓋public void paint(Graphics g, Shape a)方法。獲取圖像並調整其大小。

getScaledInstance(WIDTH, HEIGHT, Image.SCALE_AREA_AVERAGING) 

用你最喜歡的比例尺HINT最後畫出來。

相關問題