Skip to main content
Up and Coming
June 15, 2013

Splitting .mpo files in runtime with Unity?

Basically the title says it all :)

I'm creating a stereo photo viewer for the Oculus, think viewmaster but then EPIC!




The viewer works fine, but the user has to split the images by hand. I was wondering
if anyone knows how to split the .mpo files in runtime ?

Hope someone can help me out!

Thanks,
Daniel!
    This topic has been closed for replies.

    3 replies

    Up and Coming
    June 15, 2013
    Possible code head start:
    https://github.com/dmitrybrant/MpoViewer'>
    https://github.com/dmitrybrant/MpoViewer

    I just skimmed it, but looking at Form1.cs is seems like he's reading in the full byte array and just lobbing off the second half with an offset value. Apparently the MPO is two standard jpgs stored in the same file with a delimiter somewhere marking the end of the first image and start of the next.

    You should be able to load it into unity as a text asset, split the byte array (in half, or by some delimiter, not sure there) and load the bytes into two separate images with Texture2D.LoadImage.

    All a big guess on my part though :-D
    Inspiring
    June 17, 2013
    Yes. MPO is basically just 2 JPEG files concatenated together. You can just read in the hex-code and split it into two, then read in the results as JPEG. If I remember correct you are looking for 0xD8, which indicates the start of the image ( http://en.wikipedia.org/wiki/JPEG#Syntax_and_structure ). Not sure exactly how that would work in Unity though.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Up and Coming
    June 27, 2013
    Heya Everybody,

    Thanks for the fast replies, forgot to check the notify me when a reply is posted box :).

    CosbyTron & Cyber Realtiy: sounds doable. Thanks for the tips! I will look into it asap and report back. I don't know what a byte array is YET, but luckily unity is well documented! Sometimes I forget I'm an artist :)
    Stay Updated : http://www.facebook.com/shoeboxdiorama Visit my site: http://www.theshoeboxdiorama.com Twitter: @camefrombeyond Download Diorama no.1 : Blocked In : https://share.oculusvr.com/app/blocked-in‎