문제

I have a windows c++ application that creates a memory mapped file for a bitmap that is updated frequently. I would like to access to this memory mapped file to display the live image in a java application. How can I do that?

I know that FileChannel can be mapped to memory but I cannot see how to access a memory mapped file created by another process.

I already use JNA in my java application, should I use it to access standard windows memory mapped files functionality?

Or do you have any other solution than the memory mapped file to display a live image stream in java from an image created by a separate program?

도움이 되었습니까?

해결책 2

I have finaly used jna and the platform library that they provide. The Kernel32 package offers access to the CreateFileMapping and MapViewOfFile functions.

다른 팁

There is a code sample here that does what you want using JNI to bridge from C++ (Win32 memory mapped files) to Java. Might just work as is, although some cleanup for security and threading might be needed depending on your scenario.

A memory mapped file is still a file. You could read it with java.io, or you could use a MappedByteBuffer from java.nio if you want it memory-mapped in Java too.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top