예제 #1
0
LRESULT CAboutDlg::OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
/*
	HBITMAP hPicture = LoadBitmap(_Module.GetModuleInstance(), MAKEINTRESOURCE(IDB_LOGO));

	BITMAP bm;
	GetObject(hPicture, sizeof (BITMAP), (LPSTR)&bm);

	CMemDC memdc((HDC)wParam, NULL);
	HDC hdcCompatible = CreateCompatibleDC(memdc);
	HBITMAP hOldBMP = (HBITMAP)SelectObject(hdcCompatible, hPicture);
	RECT rcClient;
	GetClientRect(&rcClient);
	memdc.FillSolidRect(&rcClient, GetSysColor(COLOR_3DFACE));

	memdc.TransparentBlt(107-bm.bmWidth/2, 116-bm.bmHeight/2, bm.bmWidth, bm.bmHeight, hdcCompatible, 
						 0, 0, bm.bmWidth, bm.bmHeight, 0xff00ff);

	SelectObject(hdcCompatible, hOldBMP);
	DeleteDC(hdcCompatible);
	DeleteObject(hPicture);
/*/
	CImage Image;
	LoadImage(&Image, _Module.GetModuleInstance(), IDB_LOGO);

	CMemDC memdc((HDC)wParam, NULL);

	RECT rcClient;
	GetClientRect(&rcClient);
	memdc.FillRect(&rcClient, COLOR_3DFACE);
	Image.AlphaBlend(memdc, 107-Image.GetWidth()/2, 116-Image.GetHeight()/2, Image.GetWidth(), Image.GetHeight(), 0, 0, Image.GetWidth(), Image.GetHeight());
/**/
	return 0;

}
예제 #2
0
static void BlendSelSign( CImage &back, const RectF &render_rect, int sel )
{
    CFileListManager &file_manager = GetInst( CFileListManager );
    CImage img;
    CreateImgFromBuffer( file_manager.GetSelSign( sel ), img );
    PointF render_pos = GetRandPosInULRect( img.GetWidth(), img.GetHeight(), render_rect );
    back.AlphaBlend( &img, render_pos.X, render_pos.Y, 1.0f );
}
예제 #3
0
static void GenSmallImage( int img_count, CImage &back, const RectF &render_rect, int sel, CImage &img_alpha )
{
#define RAND_ALPHA ( ( 130 + random( 50 ) ) / 255.0f )
#define ROT_ANGLE ( random( 20 ) + 160 )
    if( img_count < 1 )
    {
        return ;
    }

    CFileListManager &file_manager = GetInst( CFileListManager );

    const Range &alpha_r = GetInst( CConfiger ).GetSystem().AnswerAlphaRange;
    float fAnswerAlpha = ( random( alpha_r.second - alpha_r.first ) + alpha_r.first ) / 255.0f;
    CImage img_first;
    CreateImgFromBuffer( file_manager.GetRandSmall(), img_first, true );
    float fFirstRot = ROT_ANGLE;
    float fFirstAlpha = RAND_ALPHA;
    PointF pos = RotateImage( img_first, img_alpha, img_count == 1 ? ( random( 60 ) - 30.0f ) : fFirstRot );
    PointF render_pos = GetRandPosInULRect( img_first.GetWidth(), img_first.GetHeight(), render_rect );
    RectF img_rect( render_pos.X + 20, render_pos.Y + 20, img_first.GetWidth() - 40, img_first.GetHeight() - 40 );
    back.AlphaBlend( &img_first, render_pos.X, render_pos.Y,
                     img_count == 1 ? fAnswerAlpha : fFirstAlpha );

    CImage *img_cover = NULL;
    PointF rot_pos = GetRotPos( img_alpha, pos );
    float fRotQuo = 20.0f;
    float fAlphaQuo = -0.08f;
    for( int i = 1; i < img_count; ++ i, fRotQuo += fRotQuo, fAlphaQuo += fAlphaQuo )
    {
        img_cover = MP_NEW CImage();
        CreateImgFromBuffer( file_manager.GetRandSmall(), *img_cover, true );
        img_cover->RotateEx( fFirstRot + fRotQuo, rot_pos.X, rot_pos.Y );
        img_cover->SetAlphaMap( &img_alpha, pos.X, pos.Y );
        back.AlphaBlend( img_cover, render_pos.X, render_pos.Y, fFirstAlpha + fAlphaQuo );
        MP_DELETE(img_cover);
    }

    BlendSelSign( back, img_rect, sel );
}
예제 #4
0
CQuestionManager::Question CQuestionManager::GenOneQuestion()
{
    Question ques = { { 0 }, 0 };
    CFileListManager &file_manager = GetInst( CFileListManager );
    int r = 0;

    // alpha image
    CImage img_alpha;
    CreateImgFromBuffer( file_manager.GetAlpha(), img_alpha );

    // 1.generate the background.
    CImage back;
    CreateImgFromBuffer( file_manager.GetRandBack(), back );
    r = random( 3 );
    CImage *img_cover;
    for( int i = 0; i < r; ++ i )
    {
        img_cover = MP_NEW CImage();
        CreateImgFromBuffer( file_manager.GetRandBack(), *img_cover );
        back.AlphaBlend( img_cover, 0, 0, ( random( 55 ) + 100 ) / 255.0f );
        MP_DELETE(img_cover);
    }

    // 2.generate small pictures.
    ques.answer = BlendSmallImage( back, img_alpha );

    // 3.covert the image to raw buffer.
    if( !back.ExportJpegToMemory( (BYTE*&) ques.data.buf, (DWORD&) ques.data.size, 85 ) )
    {
        ques.data.buf = 0;
        ques.data.size = 0;
        PutoutLog( LOG_FILE, LT_ERROR, "Export jpeg failed." );
    }

    DumpImage( &back );
    return ques;
}