Transferring Images from Windows (Phone) Runtime Components (C ++ / cx) to Native C ++ Algorithms

I am looking for a demo / tutorial on how to transfer images from my Windows Runtime components to my own algorithms.

1) Should I transfer file paths in the system and upload images of my naive library?

2) Should I pass byte arrays?

Can I process it to use both the file system and, possibly, the live stream from the camera?

Comments: I could leave some data, sorry, the algorithm used for image processing is a cross-platform implementation in C ++. I want to show this in WP8 and Win8 applications. So I need to get the images from the user interface in Runtime-Components, and then to the C ++ libraries. I agree that I do not want to decrypt it several times. I just need some advice / example of how this will look in the code. I agree that somehow it would be to direct pointers to the Runtime component (the API between the algorithm and the App).

It would also be nice for this if there was any way to deal with how the image memory layout is presented in the application in such a way that it fits into the design of the algorithm. An OpenCV ect would have a BGRBGRBGR layout for a 1 x 3 pixel rgb image. (I hope this will further strengthen my question)

0
source share
1 answer

C ++ / CX is native code, and there should be no need to duplicate the data passing it between the C ++ / CX assembly to pure C ++. Decoding a compressed image twice is something that is best avoided, as it takes a little time, so this is the main reason I would recommend passing a pointer to the bitmap image data rather than duplicating bytes if it’s really not necessary, and the image is not too large. Ideally, you should use a raster image format that can be used both for displaying an image (if you want to display it) and for processing bytes, for example. use WriteableBitmap to display the image and access the pixels to process it, or use DirectX for both. Note how much memory your bitmap uses before deciding to duplicate it - a decoded 8 megapixel photo probably uses about 32 MB of memory.

EDIT * (more)

I believe Silverlight uses the PRGBA pixel format in general, including the WriteableBitmap, which you usually use for image processing. Since you did not mention either Silverlight or DirectX, I assume that you are using the Silverlight API for your application. In this case, your simple choice is to simply use Silverlight to display the image and use the WIC in your library to decode it again in the bitmap buffer using the correct pixel format so that you can transfer it to the image processing algorithm library and then use WIC again to encode it (most likely in png or jpg). A better solution might be to use DirectX interop to avoid having to go through a decoding / encoding / decoding (...) sequence every time you want to process an image and display it on the screen. I think that you can then decode the image into the buffer with WIC and then use DirectX to display it, since I think DirectX should be able to display the image regardless of the pixel format used.

0
source

Source: https://habr.com/ru/post/947312/


All Articles