Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Dec 2013
    Posts
    3

    Confused - JpegTools BlendAsync must be RGBA

    I am rendering a WPF UI element to a WritableBitmap which is therefore BGRA32
    I would like to take this writableBitmap and render it on top of a JPEG using the JpegTools method BlendAsync.

    When I try to do it I get an exception saying BGRA32 is not RGBA32, I get that.

    How do I convert it into RGBA32 and provide it as a IReadableBitmap to BlendAsync?

    Does anyone have any ideas? This is killing me?

    I mean I know how to bit shift an int to get R,G,B,A values of course.

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    529

    Re: Confused - JpegTools BlendAsync must be RGBA

    When creating a Bitmap-object from the Nokia Imaging SDK you can define the ColorMode it uses in the constructor. If you use an WritableBitmapSource and render from that to a new Bitmap with the right ColorMode using a BitmapRenderer that should solve your issue. The value to be used during creation of your target Bitmap needs to be ARGB8888 (8bits per color component), a WritableBitmap and most of the SDK uses BGRA8888 by default.

  3. #3
    Registered User
    Join Date
    Dec 2013
    Posts
    3

    Re: Confused - JpegTools BlendAsync must be RGBA

    Thanks, could you give me an example?
    I have currently solved it but I am not happy with the solution. It seems memory efficient at least. I assume rendering from a WritableBitmapSource to a new bitmap using the BitmapRenderer would be a waste of memory?

    The way I currently solved it:

    1. Render UI element to WritableBitmap
    2. Using Pixels[] go and manually bit shift the int32 around to change BGRA32 to ARGB32
    3. Create new Nokia Bitmap from an array specifying the ColorMode. Array is the writableBitmaps Pixels[]
    This seems relatively memory efficient as the pixels are all referenced however it seems clumsy.

    I would love some more advice if you have any.

    Quote Originally Posted by SB Dev View Post
    When creating a Bitmap-object from the Nokia Imaging SDK you can define the ColorMode it uses in the constructor. If you use an WritableBitmapSource and render from that to a new Bitmap with the right ColorMode using a BitmapRenderer that should solve your issue. The value to be used during creation of your target Bitmap needs to be ARGB8888 (8bits per color component), a WritableBitmap and most of the SDK uses BGRA8888 by default.

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    529

    Re: Confused - JpegTools BlendAsync must be RGBA

    Memory wise I don't think you can do better than your solution. The reason I suggested to use the rendering of the SDK is that it's likely to be more optimized for speed although I don't know your code. I'm also not really sure if it's a good idea to directly wrap a WritableBitmap's backing buffer inside a Nokia Bitmap but if it's working for you without any issues I don't see why not to do it.

  5. #5
    Registered User
    Join Date
    Dec 2013
    Posts
    3

    Re: Confused - JpegTools BlendAsync must be RGBA

    I agree but this is a throw away render and it unwinds fine so it seems efficient to do it this way.
    My conversion code is simple, obviously not using bitconverter, that is a horrible class.
    Thanks for the help.

Similar Threads

  1. Confused..
    By stegemann in forum [Archived] Qt SDKs and Tools
    Replies: 9
    Last Post: 2010-05-23, 11:22
  2. For those who are confused what Ovi actually is...
    By themetesting in forum [Closed] Publishing to Nokia Store
    Replies: 1
    Last Post: 2009-06-02, 00:01
  3. now i'm REALLY confused! >_< ( nokia v se? )
    By akira82 in forum Mobile Java General
    Replies: 5
    Last Post: 2005-04-02, 18:14
  4. Confused about TLS!!
    By mayur_24 in forum Symbian
    Replies: 1
    Last Post: 2004-10-29, 10:08
  5. Confused........
    By ntsing in forum Bluetooth Technology
    Replies: 1
    Last Post: 2002-09-26, 07:03

Posting Permissions

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