Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Image quality when using CExtLabel as pictureholder Collapse All
Subject Author Date
Carsten Pedersen Apr 8, 2011 - 7:08 AM

Hi,

I’m subclassing CExtLabel, and am using it as a static image placeholder. I have a CExtBitmap as a member in the class, which I’m initializing like this:

    g_ResourceManager->LoadBitmap(m_Image, IDB_BITMAP_QUESTION);
    m_Image.Make32();

    // mark magenta color pixels as transparent
    COLORREF clrTransparent = RGB(255,255,255); // magenta
    m_Image.AlphaColor( clrTransparent, RGB(0,0,0), BYTE(0) );
    SetImageMode(CExtLabel::eStretch);

    SetBitmapEx(&m_Image);

My problem is, even though I set the Image mode to eStretch, the image quality looks like ColorOnColor, not Halftone. I have stepped into CExtLabel::DoPaint method, and it correctly calls
        if( eImageMode == eStretch )
            m_bmp.AlphaBlendSkinParts( dc.GetSafeHdc(), rcClient, CRect(0,0,0,0), CExtBitmap::__EDM_STRETCH, true, bSmootherAsPossible);

Is there something I’m doing wrong?

If I on the other hand, use a ATL::CImage as my image class, and make my class OwnerDraw, I can get the desired quality when using these methods in the DrawItem overloaded function:
    SetStretchBltMode(lpDrawItemStruct->hDC, HALFTONE);
    SetBrushOrgEx(lpDrawItemStruct->hDC, 0, 0, nullptr);
    m_Image.StretchBlt(lpDrawItemStruct->hDC, rc);

(However, this poses a problem, namely that I cannot define a transparent color, hence the border of my circular image is white)

Thanks in advance,

Carsten Pedersen

Technical Support Apr 12, 2011 - 2:27 AM

We confirm this. Here is the test project we used:
http://www.prof-uis.com/download/forums/TestImageLabel.zip
We found that the problem is actually not a problem. This is behavior of the AlpaBlend() Win32 API from <b>MsImg32.DLL</code> module. This is probably surprising change of Windows 7 because SetStretchBltMode() Win32 API affects both StretchBlt() and AlphaBlend() APIs in older Windows versions. We can provide you with a workaround. Please try to un-comment the following two lines in our test project and see the Adobe Photoshop image stretching quality inside scaled CExtLabel control:

//CExtBitmap:: Filter _f( CExtBitmap::Filter::b_spline );
//    VERIFY( m_Image.Scale( 1024, 1024, _f ) );

Carsten Pedersen Apr 12, 2011 - 1:08 PM

Thank you, with the desired scaling input, it yielded satisfactory results!


As a side note - I tried to use static libs with your test project, however it asserted in the following line:



VERIFY( m_bmpFilterApplied.LoadBMP_Resource( MAKEINTRESOURCE( IDB_EXT_BITMAP_FILTER_APPLIED ) ) );


In ExtPaintManager.cpp. There is no problem with the DLL version of profUIS. Why is this?


Technical Support Apr 13, 2011 - 1:07 PM

Please drop us an e-mail to the support mail box at this web site so we will provide you with the fix for this resource loading issue.

Carsten Pedersen Apr 11, 2011 - 12:36 AM

I saw that after I posted the message, that I had made a comment error. We want to have white as transparent, so the comment is wrong. There is no problem with transparency, as the white in the image is correctly treated as transparent.


So I’m still experiencing the low quality issue. As I wrote, If I replace your code with the ATL::CImage variant, the image i nicely smoothed, but transparency is not done.

Technical Support Apr 9, 2011 - 7:37 AM

First of all, you wrote:

COLORREF clrTransparent = RGB(255,255,255); // magenta
The RGB(255,255,255) color is white. The RGB(255,0,255) color is magenta.
Second, the eImageMode enumeration defines how to draw image - not which quality of stretching to use. The bSmootherAsPossible flag parameter set to true specifies the halftone stretching should be used. The CExtLabel draws using halftone stretching by default. We suspect the problem is in the incorrect magenta color.