×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    510

    Imaging SDK 1.0 Feedback Competition: SB Dev: Native Implementation of IBuffer needed

    When working with the Nokia Imaging SDK 1.0 using native code you will sooner or later run into a situation where you have to create an instance of a class implementing the Windows::Storage::Streams::IBuffer interface. Unfortunately WP8 does not provide a class you can simply use to get such an instance and neither does the Imaging SDK.

    While there is a BufferFactory in the Nokia::InteropServices Namespace you can only use it if you have a class implementing the ILockableMemory interface, which we don't. Also the descriptions of the Lock/Unlock methods indicates a connection with actual Interop functionality involving the Garbage Collector. Implementation would also be difficult given that the interface does not provide a way to pass in/out the actual memory pointer. On the managed side this Namespace also contains Extension methods to create an IBuffer from integer arrays but this unfortunately is not available from native code.

    So currently the only way to get such a Buffer is to implement it ourselves which involves working with the Windows Runtime C++ Template Library (WRL) which is quite complex to work with if you're not used to COM or ATL programming. Most implementations I've seen so far are based on this one: http://stackoverflow.com/questions/1...t-ibuffer-in-c

    While we of course can get custom effects written in native code working by using our custom implementation of an IBuffer it takes quite a bit of research to get to this point. I assume that some way to create Buffers in native code is already implemented in the Imaging SDK so I hope that it can be surfaced in the public APIs easily.

    I am facing this issue when implementing the Nokia::Graphics::Imaging::ICustomEffect interface but have seen it mentioned in other cases as well.

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    472

    Re: Imaging SDK 1.0 Feedback Competition: SB Dev: Native Implementation of IBuffer ne

    You can use Windows::Storage::Streams::buffer :
    http://msdn.microsoft.com/en-US/libr...streams.buffer

    A IBuffer it's a class which must implement the IBuffer WinRT interface and Windows::Storage::Streams::IBufferByteAccess COM interface


    Code:
    So currently the only way to get such a Buffer is to implement it ourselves which involves working with the Windows Runtime C++ Template Library (WRL) which is quite complex to work with if you're not used to COM or ATL programming. Most implementations I've seen so far are based on this one: http://stackoverflow.com/questions/1...t-ibuffer-in-c
    I use veri similare (identic?)code to interface native memory.
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    510

    Re: Imaging SDK 1.0 Feedback Competition: SB Dev: Native Implementation of IBuffer ne

    That's what I thought originally but somehow when I get a Buffer instance using Buffer's constructor initialized to (4 * size.Height * size.Width) I get an exception when providing that Buffer back to the calling code inside the ProvideSourceBuffer-method, complaining that it was of inssuficient size (the given size that was required actually was the same as the one returned by the Buffer's Capacity Property). I tried manually initalizing the Buffer larger than what would be needed but I still kept seeing the Exception.

    That led me to the conclusion that using the constructor of the Buffer class (WinRT - component?) the backing array was not being created correctly.

    Have you implemented an ICustomEffect and would be willing to share your code for the ProvideSourceBuffer-method? I'll post the code I tried to use there along with the detailed exception when I get home later.

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    472

    Re: Imaging SDK 1.0 Feedback Competition: SB Dev: Native Implementation of IBuffer ne

    It's because you have set the capacity but not it's size
    It's not the same things

    Code:
    auto outBuffer = ref new Windows::Storage::Streams::Buffer(4*info->ImageSize.Width*info->ImageSize.Height);
    outBuffer->Length = outBuffer->Capacity;
    I've udpate the sample here : http://developer.nokia.com/Community...with_a_picture


    I'll update article shortly.
    Look Direct3DInterop.cpp the function
    • Windows::Foundation::IAsyncAction^ CreateTextureFromFileAsync(Windows::Storage::Streams::IBuffer^ file);
    • Windows::Foundation::IAsyncAction^ CreateTextureFromFileAsync(Windows::Storage::Streams::IBuffer^ file,int with,int height);
    • Windows::Foundation::IAsyncOperation<Windows::Storage::Streams::IBuffer^>^ TakeSnapShotAsync(int width,int height);
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    510

    Re: Imaging SDK 1.0 Feedback Competition: SB Dev: Native Implementation of IBuffer ne

    That did the trick - thanks a lot!

    What I really wonder though is why there are so many articles out there dealing with a custom implementation. Especially that not a single one mentioned the actually simple solution you gave me.

    Great help as always
    Last edited by SB Dev; 2013-12-05 at 12:15.

Similar Threads

  1. Nokia Imaging and Big UI Wiki Competition 2013Q4 - articles and feedback
    By hamishwillee in forum Windows Phone Imaging
    Replies: 1
    Last Post: 2013-12-24, 04:33
  2. Replies: 9
    Last Post: 2013-11-30, 20:24
  3. Replies: 2
    Last Post: 2013-11-26, 15:47
  4. Nokia Imaging SDK Feedback (Competition)
    By skalogir in forum Windows Phone Imaging
    Replies: 77
    Last Post: 2013-11-15, 00:22
  5. Replies: 7
    Last Post: 2012-07-25, 01:25

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×