[英]Does the resulting image from using ImageIO.read() still use the same memory passed to it?
I am working on an OpenGL project which requires me to implement the JVM through the JNI library to use JavaGraphics2D for rendering to an OpenGL mapped buffer in c++. 我知道我可以使用指向映射緩沖區的void*
指針創建java.nio.ByteBuffer
object:
jobject NewDirectByteBuffer(JNIEnv* env, void* address, jlong capacity);
如果我通過將此ByteBuffer
轉換為byte[]
數組,將該數組包裝在ByteArrayInputStream
周圍並使用ImageIO.read()
,最終BufferedImage
仍將使用與void*
指針相同的 memory 進行存儲或使用ImageIO 方法為 BufferedImage 存儲分配新的 memory? 即,如果我使用 Java2DGraphics 繪制到 BufferedImage 上,是否會導致原始 void* memory 也被更改?
如果不是這種情況,我將不得不將 BufferedImage 數據復制到 ByteBuffer
ImageIO.read 處理各種輸入源並分配自己的 memory,它不與它返回的 BufferedImage 共享您的原始 byte[]。
所以你需要調用 ImageIO.write 來取回修改。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.