Alphablending from C++ and from .NET (C#)

  • To use alphablend from your C# application please read: http://blogs.msdn.com/chrislor…ve/2006/04/07/570649.aspx


    Sample source code to display BMP files with alpha channel (A8 R8 G8 B8):



    Sample source code to display PNG files (also with alpha channel):



    DKuhne.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello Support-Team,
    we use PicoMod 6 and i have tried this example here, but it can't be compiled.
    I´ve got the following error:
    error LNK2001: Nicht aufgelöstes externes Symbol "CLSID_ImagingFactory"


    I used the includes:
    imaging.h
    initguid.h
    imgguids.h


    and linked to library:
    imaging.lib


    and Visual Studio 2008 on Windows 7.


    I will write a multithread Application and therefore the DCOM solution is not really the best
    way to use alphablending. Do you know another solution ?


    Why it is not possible to use CImage::Load ? The function is described in the documentation, but not available
    in the SDK ?


    Thanx, Axel Koch

  • Hello,

    Quote

    error LNK2001: Nicht aufgelöstes externes Symbol "CLSID_ImagingFactory"

    Thats stange! CLSID_ImagingFactory is defined in imgguids.h:

    Code
    1. ///DEFINE_GUID(CLSID_ImagingFactory, 0x327abda8,0x072b,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);


    It helps to change include order as following:

    C
    1. #include <initguid.h>
    2. #include <imaging.h>
    3. #include <imgguids.h>


    Quote

    Why it is not possible to use CImage::Load ? The function is described in the documentation, but not available
    in the SDK ?

    From where did you get this infomation? We are using Windows Embedded CE 6.0 R3 on PicoMOD6 at the time.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hm,
    i tested it in my enviroment and it works. I did not add any additional LIBs and did not modify standard search pathes.
    As a temporary workaround you may define "CLSID_ImagingFactory" in your source file.


    PS: Did you install latest SDK from http://www.fs-net.de/download/bin/?

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • I do not understand why it does not work.


    Yes, i downloaded the latest SDK this week. But, i have installed it without documentation (custom),
    because i have got an error while installing it.
    I use Windows 7 and Visual Studio 2008.


    Regards, ak

  • Hello,
    i attach my project. Maybe other includes in your project cause the problems?

    Files

    • PNGLoad.zip

      (2.62 MB, downloaded 283 times, last: )

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello,
    why do you add the includes to stdafx.h? You need they only one time.
    Add:

    C
    1. #include <initguid.h>
    2. #include <imaging.h>
    3. #include <imgguids.h>

    to "SLK2_test1Dlg.cpp" after local includes this should work.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello,


    now i have another problem using IImage::Draw to draw PNG Images.
    I tested the draw routine with a lot of PNG´s, in my case up to 50.
    The performance is not good, because it takes more than 20 seconds to draw all
    PNG´s into the CDC.
    (20s are only possible, if i use the third parameter of the IImage::Draw routine "srcRect", but sometimes
    PicoMod6 makes an reboot while drawing)
    (If i do not use the "srcRect" Parameter, it will never come back and PicoMod6 makes an reboot)


    Regards, ak


    I use following code:


    int d = 55;
    for(int i = 1; i < 57; i++)
    {
    if( i <= 14 )
    {
    rcDst.MoveToXY( d*(i-1), 0 );
    }
    if( i > 14 && i <= 28 )
    {
    rcDst.MoveToXY( d*(i-1-14), 70 );
    }
    if( i > 28 && i <= 42 )
    {
    rcDst.MoveToXY( d*(i-1-28), 140 );
    }
    if( i > 42 && i <= 56 )
    {
    rcDst.MoveToXY( d*(i-1-42), 210 );
    }


    if( arrResult.GetAt(i) == S_OK )
    {
    hr = arrPNGs.GetAt(i)->Draw( m_dc.m_hDC, &rcDst, &rcSrcMM );
    if( hr != S_OK )
    {
    CString s;
    s.Format(L"Error in Show_new hr: [%d]", hr );
    AfxMessageBox( s, MB_OK );
    }
    }
    Sleep(100); //without sleep -> PicMod6 reboots
    }

  • Hello,
    can you send me whole project and PNGs to my email address?
    I will investigate the problem.
    Thanks.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello,
    thanks agian for your samlpe. I did some investigations:

    Quote

    IImage::Draw
    ...If i do not use the "srcRect" Parameter, it will never come back and PicoMod6 makes an reboot.
    ...Sleep(100); //without sleep -> PicMod6 reboots

    I can set "srcRect" to NULL and i can use IImage::Draw without Sleep()!!! Do you use latest SW. I test on PicoMOD6 with kernel V1.02 and EBoot V1.01.


    Quote

    The performance is not good, ...

    I think we can increase the performance drastically (i test it also on NetDCU9 with nearly the same result). If you need faster transparent drawing you should check following:
    - Is "TransparentBlt" sufficient for your purpose?
    - Does use of DDraw helps?
    - PRO kernel for PicoMOD6 offers OpenGL
    In general you can try to direct access to the bitmaps data.


    Hop this helps.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello,


    this is the output of the Bootloader:


    I think i have the newest one !


    Regards, ak

  • Hello,


    we need semi transparent drawing and if i understand TransparentBlt correct, it can only do transparent
    or not transparent drawing but noting between.


    Where can i find DDraw?


    I have no experience with OpenGL and i thing it costs more than current kernel ?


    Do you think an owner written function for alphablending is much faster than the IImage::Draw function ?
    ( we will use png´s and not bitmaps )


    Regards, ak

  • Hello,


    Quote

    we need semi transparent drawing and if i understand TransparentBlt correct, it can only do transparent
    or not transparent drawing but noting between

    Right.

    Quote

    Where can i find DDraw?

    DDraw is a part of the SDK. Include ddraw.h and link agaist ddraw.lib. For details refer http://msdn.microsoft.com/en-us/library/ee491091.aspx.

    Quote

    I have no experience with OpenGL and i thing it costs more than current kernel ?

    I think we can offer you a custom kernel with core licenz (ask <!-- e --><a href="mailto:sales@fs-net.de">sales@fs-net.de</a><!-- e -->). Or you can purchase it from a third party.

    Quote

    Do you think an owner written function for alphablending is much faster than the IImage::Draw function ?
    ( we will use png´s and not bitmaps )

    I dont know. I think you have to do some quick tests.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.