簡體   English   中英

將位圖轉換為java.awt.image.BufferedImage

[英]Converting Bitmap into java.awt.image.BufferedImage

我在C#項目中使用IKVM庫。 我可以使用這些庫定義BufferedImage,也可以將Bitmap用作BufferedImage源,但是存在問題。

 java.awt.image.BufferedImage fileZ =new java.awt.image.BufferedImage(new Bitmap(file));

這是錯誤:

An exception of type 'System.TypeInitializationException' occurred in IKVM.OpenJDK.SwingAWT.dll but was not handled in user code

Additional information: The type initializer for 'java.awt.image.ColorModel' threw an exception.

文件是一個字符串,是指位圖文件。 並且我將這些引用添加到我的項目中:

IKVM.OpenJDK.Core
IKVM.OpenJDK.SwingAWT
IKVM.OpenJDK.Util
IKVM.Runtime

我該如何解決這個問題?

您的問題沒有足夠的信息來回答。 但是, 這篇文章與您的任務有關。 這條線特別令人感興趣:

BufferedImage img = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);

最后一個參數指定圖像類型。

BufferedImage類中的其他構造函數也處理顏色模型。 去看一下。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM