×

Discussion Board

Page 1 of 3 123 LastLast
Results 1 to 15 of 34
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    30

    troubles on showing argb data in a surface control

    Hi, all
    I had met some troubles on showing argb data in a surface control in a "Windows Phone xaml and directx" project, could anyone help me , thanks!
    I found a similar question on MSDN forum http://social.msdn.microsoft.com/For...5-4e40e8380841

  2. #2
    Registered User
    Join Date
    Jul 2011
    Posts
    20

    Re: troubles on showing argb data in a surface control

    Hi!
    So what's the actual issue? Do you have a sample project which reproduces the problem?

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    30

    Re: troubles on showing argb data in a surface control

    Quote Originally Posted by AlexSorokoletov View Post
    Hi!
    So what's the actual issue? Do you have a sample project which reproduces the problem?
    Hi, thanks for the attention.
    Here are the sample project:
    http://sdrv.ms/11BzVXs

    I just want to show this girl(a.jpg) on the drawsurface control. but as you know, WIC(Windows Imaging Component) is not supported in Windows Phone, I could not user the CreateTetureFromFile API to create the Texture.
    So I changed my mind, try to like this:
    1. pass the argb data(WriteableBittmap.Pixels) to the d3d compontent
    2. create the texture according to the argb data
    3. fill the backbuffer with the texture
    4. renderring the buffer and present the buffer with swapchain

    but unfortunately, I have no diea on implementing all the above in d3d yet.
    Last edited by small2; 2013-03-28 at 02:34.

  4. #4
    Registered User
    Join Date
    Oct 2011
    Posts
    30

    Re: troubles on showing argb data in a surface control

    Could anyone help me?

  5. #5
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    474

    Re: troubles on showing argb data in a surface control

    Hi.
    You want load a jpg file as texture?

  6. #6
    Registered User
    Join Date
    Oct 2011
    Posts
    30

    Re: troubles on showing argb data in a surface control

    well , a simple work flow would like this:
    Image Data(int array,C#)------pass data----->D3D(C++,Rendering)-----show----->DrawsurfaceControl(C#,XAML)
    exactly speaking, I just want to show the image on the DrawingSurface control, and the content provider of the DrawingSurface control would be a d3d object, just like the cuberender object in the "PhoneXamlDirect3DApp1Comp" project

    DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider());

  7. #7
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    474

    Re: troubles on showing argb data in a surface control

    I don't understand WP8 directx haven't method to load jpeg/png file.

    I make an example where i read an image with Bitmap, and get pixel buffer with a WritableBitmap.
    So i give pixel buffer and image size to direct3D throw a c++method named CreateTexture which create an ID3D11Texture2D with image data.

    Example display a textured cube.

    https://skydrive.live.com/redir?resi...6D45C8F7A!3443

    Warning : WritableBitmap pixel are premultiplied_ARGB, so if your image have alpha you need convert each pixel to ARGB.
    Ps: i don't know it xaml ui thread is the same as Dx rendering thread. Maybe you need to protect concurrent access.
    Last edited by yan_; 2013-04-14 at 22:27.

  8. #8
    Registered User
    Join Date
    Oct 2011
    Posts
    30

    Re: troubles on showing argb data in a surface control

    Quote Originally Posted by yan_ View Post
    I don't understand WP8 directx haven't method to load jpeg/png file.

    I make an example where i read an image with Bitmap, and get pixel buffer with a WritableBitmap.
    So i give pixel buffer and image size to direct3D throw a c++method named CreateTexture which create an ID3D11Texture2D with image data.

    Example display a textured cube.

    https://skydrive.live.com/redir?resi...6D45C8F7A!3443

    Warning : WritableBitmap pixel are premultiplied_ARGB, so if your image have alpha you need convert each pixel to ARGB.
    Ps: i don't know it xaml ui thread is the same as Dx rendering thread. Maybe you need to protect concurrent access.
    Thanks very much, it helps me a lot! That is just what I'm looking for, dispite it seems like a little complex for me now, but I think I could handle it well.
    Last edited by small2; 2013-04-15 at 08:32.

  9. #9
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    474

    Re: troubles on showing argb data in a surface control

    if you have question about code, do not hesitate to ask

  10. #10
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    474

    Re: troubles on showing argb data in a surface control

    Hi.
    I've write a wiki article with this solution : http://www.developer.nokia.com/Commu...with_a_picture

    If you are interested, i've add conversion between premultiplied_ARGB and ARGB.

  11. #11
    Registered User
    Join Date
    Oct 2011
    Posts
    30

    Re: troubles on showing argb data in a surface control

    Quote Originally Posted by yan_ View Post
    Hi.
    I've write a wiki article with this solution : http://www.developer.nokia.com/Commu...with_a_picture

    If you are interested, i've add conversion between premultiplied_ARGB and ARGB.
    That is wonderful !

  12. #12
    Registered User
    Join Date
    Oct 2011
    Posts
    30

    Re: troubles on showing argb data in a surface control

    Quote Originally Posted by yan_ View Post
    Hi.
    I've write a wiki article with this solution : http://www.developer.nokia.com/Commu...with_a_picture

    If you are interested, i've add conversion between premultiplied_ARGB and ARGB.
    Hi, yan_

    When I debug the d3d compontent, the out put window print a bunch of warning s like this:

    D3D11 WARNING: ID3D11DeviceContext:rawIndexed: The Pixel Shader unit expects a Sampler to be set at Slot 0, but none is bound. This is perfectly valid, as a NULL Sampler maps to default Sampler state. However, the developer may not want to rely on the defaults. [ EXECUTION WARNING #352: DEVICE_DRAW_SAMPLER_NOT_SET]

    After googled, I found a simlar queation: http://stackoverflow.com/questions/1...-vertex-buffer , but unfortunately, that did not go for me.

    As your guidence, I mopdified the cubicrender class for rendering a rectangle (just drawing two trangles, as your code, four vertices, and the render index just like "0,2,1,0,3,2 "), and fill the rectangle with the picture, set the rotated matrix's value to zero. change the camera location like this:

    XMVECTOR eye = XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f);
    XMVECTOR at = XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f);
    XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);

    and modify the texture cordinate to make the texture fill the screen. to make the texture shows as original size , set aspectRatio to 1.0f before creating the matrix on CubeRenderer::CreateWindowSizeDependentResources() method.


    I also make a demo that pass the camera feed in a thread (the argb frame by calling the PhoneCaptureDevice.GetPreviewBuffer()) to replace the picture data. But unexpected things happened, the presented camera data on the Drawingsurface conntrol was not showing smoothly at all. And I also could not click the buttob over the Drawingsurface control, the applicatipon crashes soon later.

    P.S: Due to the confidentiality agreement, I can't show you the project. but the demo would likes a simple one for you in just a few steps:
    1. Initial a PhoneCaptureDevice asyncnously.
    2. After the device loaded, start a thread to pass the camera feed to the d3d compontent. Do not remember modify the WMAppManifest file to add the camera capacity.

    looking forward your replying. Thanks very much!

  13. #13
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    474

    Re: troubles on showing argb data in a surface control

    Hi.
    I do very similar thinks in my futur application (an update of MonsterCam)
    For the warning, i've read that it's not a real warning.


    Quote Originally Posted by small2 View Post
    P.S: Due to the confidentiality agreement, I can't show you the project. but the demo would likes a simple one for you in just a few steps:
    If it's with Nokia, maybe we have same confidentiality agreement.

    Quote Originally Posted by small2 View Post
    2. After the device loaded, start a thread to pass the camera feed to the d3d compontent. Do not remember modify the WMAppManifest file to add the camera capacity.
    I thinks you must protect concurrent acces. In my app, i'v add std::mutex + std::lock_guard to protect C# call with the rendering function.

    Other help:
    1- if you'll use navigation, code will crash. It's a bug on Microsoft example. To resolve it, look here : http://www.tonicodes.net/blog/wp8-xa...ng-navigation/
    2- If you want make offscreen rendering, i can explain how

    yan
    [edit]
    i've add camera support. in state of thread, i use PreviewFrameAvailable event. It's works for me.
    Last edited by yan_; 2013-06-22 at 02:37.

  14. #14
    Registered User
    Join Date
    Oct 2011
    Posts
    30

    Re: troubles on showing argb data in a surface control

    If it's with Nokia, maybe we have same confidentiality agreement.
    Acturally it was with my company worked for.

    I thinks you must protect concurrent acces. In my app, i'v add std::mutex + std::lock_guard to protect C# call with the rendering function.
    Thanks for the tips, I'll check it later.

    2- If you want make offscreen rendering, i can explain how
    That couldn ' t be better。

    i've add camera support. in state of thread, i use PreviewFrameAvailable event. It's works for me.
    Well ,dose it could render smoothly, just like the viewfinder of the native camera app?

  15. #15
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    474

    Re: troubles on showing argb data in a surface control

    Quote Originally Posted by small2 View Post
    That couldn ' t be better。
    i'll check my code when i have time.

    Quote Originally Posted by small2 View Post
    Well ,dose it could render smoothly, just like the viewfinder of the native camera app?
    yep. A little slower if you high res preview (maybe because i recreate), but you can change this resolution. I keep default preview resolution because change preview resolution take few seconds.

Similar Threads

  1. VKB is not showing up for CEikEdwin control - 5th Edition
    By ruchirvasavada in forum Symbian User Interface
    Replies: 1
    Last Post: 2011-01-06, 03:31
  2. problem:Browser control is not showing on N73 device
    By rahul.shalik.makode in forum Symbian
    Replies: 0
    Last Post: 2010-05-28, 07:24
  3. Volume control while showing a dialog
    By enigma_007 in forum Symbian
    Replies: 1
    Last Post: 2009-10-31, 08:20
  4. Copying content from Pixmap surface to window surface
    By mustaf in forum Symbian Media (Closed)
    Replies: 4
    Last Post: 2009-01-15, 06:58
  5. Control faded on showing menu pane
    By strike_noir in forum Symbian User Interface
    Replies: 5
    Last Post: 2008-10-16, 07:58

Posting Permissions

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