Exemple #1
0
HRESULT UISeperator::Draw(DK_IMAGE drawingImg)
{
    HRESULT hr(S_OK);
    if (!m_bIsVisible)
    {
        return hr;
    }
    DK_IMAGE imgSelf;
    DK_RECT rcSelf = {m_iLeft, m_iTop, m_iLeft + m_iWidth, m_iTop + m_iHeight};
    RTN_HR_IF_FAILED(CropImage(drawingImg, rcSelf, &imgSelf));

    CTpGraphics grf(imgSelf);
    if (SD_VERT == m_direction)
    {
        grf.FillRect(m_iWidth / 2, 0,
                m_iWidth / 2 + m_thickness, m_iHeight,
                ColorManager::knBlack);
    }
    else
    {
        grf.FillRect(0, m_iHeight / 2,
                m_iWidth, m_iHeight /2 + m_thickness,
                ColorManager::knBlack);
    }
    return S_OK;
}
HRESULT UIAbstractText::DrawBackGround(DK_IMAGE drawingImg)
{
    if (!m_eraseBackground)
    {
        return S_OK;
    }
    HRESULT hr(S_OK);
    CTpGraphics grf(drawingImg);
    //TODO, should get background color from m_TextDrawer
    const DK_ARGBCOLOR& bgcolor = m_TextDrawer.GetBackgroundColor();
    INT color = ~((bgcolor.rgbRed<<16 & 0xFF0000) | (bgcolor.rgbGreen<<8 & 0xFF00) | (bgcolor.rgbBlue & 0xFF));
    RTN_HR_IF_FAILED(grf.FillRect(0, 0, m_iWidth, m_iHeight, color));
    return hr;
}
void RasterOperations::testResample() {

    Ilwis::IGeoReference grf("code=georef:type=corners,csy=epsg:21037,envelope=-3.02456e+06 -4.55547e+06 6.47259e+06 4.39692e+06,gridsize=1188 1120,name=grf1");
    QString expr = QString("aa5resbic=resample(n000302.mpr,grf1,bicubic)");
    DOTEST(grf.isValid(),"making georef by code");
    QString expr = QString("aa5resbic=resample(average_monthly_temperature_january_5.mpr,plate102.grf,bicubic)");
    //QString expr = QString("aa5resbic=resample(small3.mpr,aeqsmall.grf,bicubic)");

    Ilwis::ExecutionContext ctx;
    Ilwis::SymbolTable syms;
    DOTEST(Ilwis::commandhandler()->execute(expr,&ctx,syms), "resample done.");

    Ilwis::IRasterCoverage raster("ilwis://internalcatalog/aa5resbic");
    raster->connectTo(QString("file:///%1/aa5ss.mpr").arg(_baseDataPath.absolutePath()), "map","ilwis3",Ilwis::IlwisObject::cmOUTPUT);
    raster->createTime(Ilwis::Time::now());
    raster->store();
}
HRESULT UIPdfTrimColumnedDlg::DrawBackGround(DK_IMAGE drawingImg) 
{
	DebugPrintf(DLC_ZHY,"enter %s:%s,%s(%d)",GetClassName(),__FUNCTION__,__FILE__,__LINE__);
	HRESULT hr(S_OK);
	DK_IMAGE imgSelf;
	DK_RECT rcSelf={m_iLeft, m_iTop, m_iWidth, m_iHeight};

	//drawing original image
	DK_IMAGE* backGroundImage = m_pBookReader->GetPageBMP();
	rcSelf.top     = m_iHeight > backGroundImage->iHeight? (m_iHeight - backGroundImage->iHeight) >> 1: m_iTop;
	rcSelf.bottom  = rcSelf.top + backGroundImage->iHeight;
	rcSelf.left    = m_iWidth > backGroundImage->iWidth? (m_iWidth - backGroundImage->iWidth) >> 1: m_iLeft;
	rcSelf.right   = rcSelf.left + backGroundImage->iWidth;
	CTpGraphics grf(drawingImg);
	grf.EraserBackGround(ColorManager::knWhite);
	RTN_HR_IF_FAILED(CropImage(drawingImg, rcSelf, &imgSelf));
	CopyImage(imgSelf, *backGroundImage);

	DebugPrintf(DLC_ZHY,"leave %s:%s,%s(%d)",GetClassName(),__FUNCTION__,__FILE__,__LINE__);
	return hr;
}
HRESULT UIPdfTrimColumnedDlg::Draw(DK_IMAGE drawingImg)
{
	DebugPrintf(DLC_ZHY,"enter %s::%s,%s(%d)",GetClassName(), __FUNCTION__, __FILE__, __LINE__);
	if (!IsVisible())
		return S_OK;
	HRESULT hr(S_OK);
	CTpGraphics grf(drawingImg);
	DK_IMAGE imgSelf;
	DK_RECT rcSelf={m_iLeft, m_iTop, m_iLeft + m_iWidth, m_iTop + m_iHeight};
	RTN_HR_IF_FAILED(CropImage(drawingImg, rcSelf, &imgSelf));

	RTN_HR_IF_FAILED(DrawBackGround(imgSelf));

	//draw flag
	SPtr<ITpImage> spImageCursor = ImageManager::GetImage(IMAGE_PDF_LOCATE_CURSOR);
	int w = spImageCursor->GetWidth();
	int h = spImageCursor->GetHeight();

	if (m_bIsActionFinished) 
    {
		m_btnConfirmed.SetVisible(true);
		m_btnCancel.SetVisible(true);
		RTN_HR_IF_FAILED(m_btnConfirmed.Draw(imgSelf));
		RTN_HR_IF_FAILED(m_btnCancel.Draw(imgSelf));
	} 
    else 
    {
		m_btnConfirmed.SetVisible(false);
		m_btnCancel.SetVisible(false);
	}

	//draw lines
	if (m_iCurAction == PdfTrimAction) 
    {
		//Trim
		grf.DrawImage(spImageCursor.Get(), m_iLeftCuttingEdge - w/2, m_iTopCuttingEdge -h/2);
		grf.DrawImage(spImageCursor.Get(), m_iRightCuttingEdge - w/2, m_iBottomCuttingEdge - h/2);

		DebugPrintf(DLC_ZHY,"rect,left,top,right,bottom:%d,%d,%d,%d",m_iLeftCuttingEdge, m_iTopCuttingEdge, m_iRightCuttingEdge, m_iBottomCuttingEdge);
		grf.DrawLine(m_iLeftCuttingEdge, m_iTop, 2, m_iHeight, SOLID_STROKE);
		grf.DrawLine(m_iRightCuttingEdge, m_iTop, 2, m_iHeight, SOLID_STROKE);
		grf.DrawLine(m_iLeft, m_iTopCuttingEdge, m_iWidth, 2, SOLID_STROKE);
		grf.DrawLine(m_iLeft, m_iBottomCuttingEdge, m_iWidth, 2, SOLID_STROKE);
	}
    else 
    {
		grf.DrawLine(m_iColumnedX, m_iTop, 2, m_iHeight, SOLID_STROKE);
		grf.DrawImage(spImageCursor.Get(), m_iColumnedX - w/2, m_iColumnedY - h/2);

		if (m_iCurAction==PdfColumnedComicOrderLR || m_iCurAction==PdfColumnedComicOrderRL) 
        {
			//split to 2 pages
		} 
        else 
        {
			//split to 4 pages
			grf.DrawLine(m_iLeft, m_iColumnedY, m_iWidth, 2, SOLID_STROKE);
		}
	}
	if (m_btnTips.IsVisible())
		m_btnTips.SetVisible(false);

	DebugPrintf(DLC_ZHY,"leave %s::%s,%s(%d)",GetClassName(), __FUNCTION__, __FILE__, __LINE__);

	return hr;
}
Exemple #6
0
HRESULT UITouchButton::Draw(DK_IMAGE drawingImg)
{
	DebugPrintf(DLC_CHENM, "UITouchButton::Draw()  Start");

    if (!m_bIsVisible)
    {
	    DebugPrintf(DLC_CHENM, "UITouchButton::Draw()  End: m_bIsVisible = false");
        return S_OK;
    }

    if (drawingImg.pbData == NULL)
    {
	    DebugPrintf(DLC_CHENM, "UITouchButton::Draw()  End: m_bIsVisible = false");
        return E_FAIL;
    }

    HRESULT hr(S_OK);
    DK_IMAGE imgSelf;
    DK_RECT rcSelf={m_iLeft, m_iTop, m_iLeft + m_iWidth, m_iTop + m_iHeight};
    RTN_HR_IF_FAILED(CropImage(
                            drawingImg,
                            rcSelf,
                            &imgSelf
                            ));

    CTpGraphics grf(imgSelf);


    if (m_bUsingBackgroundPicture)
    {
        // draw background picture if there is
        if (IsFocus() || IsPressed())
        {
            if (m_spFocusedBackground)
            {
                    HRESULT hr(S_OK);
	                DebugPrintf(DLC_CHENM, "UITouchButton::Draw()  Draw background Image  in focus");
                    int startx = (m_iWidth - m_spFocusedBackground.Get()->GetWidth());

                    if (startx >0)
                        startx = startx / 2;
                    else
                        startx =0;

                    int starty = (m_iHeight - m_spFocusedBackground.Get()->GetHeight());

                    if (starty >0)
                        starty = starty / 2;
                    else
                        starty =0;

                    RTN_HR_IF_FAILED(grf.DrawImage(m_spFocusedBackground.Get(),startx,starty,0,0,m_spFocusedBackground.Get()->GetWidth(), m_spFocusedBackground.Get()->GetHeight()));
                    //RTN_HR_IF_FAILED(grf.DrawImage(m_spFocusedBackground.Get(), 0, 0));
            }
        }
        else
        {
            if (m_spBackground)
            {
	                DebugPrintf(DLC_CHENM, "UITouchButton::Draw()  Draw background Image not in focus");

                    int startx = (m_iWidth - m_spBackground.Get()->GetWidth());

                    if (startx >0)
                        startx = startx / 2;
                    else
                        startx =0;

                    int starty = (m_iHeight - m_spBackground.Get()->GetHeight());

                    if (starty >0)
                        starty = starty / 2;
                    else
                        starty =0;

                    HRESULT hr(S_OK);
                    RTN_HR_IF_FAILED(grf.DrawImage(m_spBackground.Get(), startx, starty, 0, 0, m_spBackground.Get()->GetWidth(), m_spBackground.Get()->GetHeight()));
                    //RTN_HR_IF_FAILED(grf.DrawImage(m_spBackground.Get(), 0, 0));
            }
        }
    }
    else
    {
        // draw background in color
        if (!m_bBackTransparent)
        {
            if (IsFocus() || IsPressed())
            {
	            DebugPrintf(DLC_CHENM, "UITouchButton::Draw()  Draw background with color in focus");
                RTN_HR_IF_FAILED(grf.FillRect(
                    0,
                    0,
                    m_iWidth,
                    m_iHeight,
                    m_focusedBackgroundColor));
            }
            else
            {
	            DebugPrintf(DLC_CHENM, "UITouchButton::Draw()  Draw background with color not in focus");
                RTN_HR_IF_FAILED(grf.FillRect(
                    0,
                    0,
                    m_iWidth,
                    m_iHeight,
                    GetBackgroundColor()));
            }
        }
    }
    //draw string
    if (m_strText.Length() > 0)
    {
        m_ifontAttr.m_iFace=FONT_DEFAULT;
        
        ITpFont* pFont = NULL;

        if (IsFocus() || IsPressed())
        {
            pFont = FontManager::GetInstance()->GetFont(m_ifontAttr, m_iFocusedFontColor);
        }
        else
        {
            pFont = FontManager::GetInstance()->GetFont(m_ifontAttr, GetFontColor());
        }

        if(NULL == pFont)
        {
	        DebugPrintf(DLC_CHENM, "UITouchButton::Draw()  End: pFont = NULL");
            return E_FAIL;
        }

        int _iStringWidth = pFont->StringWidth(m_strText);
        int _iStringHeight = pFont->GetHeight();

        if (_iStringWidth > m_iWidth)
        {
	        DebugPrintf(DLC_CHENM, "UITouchButton::Draw()  End:_iStringWidth > m_iWidth");
            return E_FAIL;
        }

        int _H_offset = (m_iWidth - _iStringWidth) / 2;
        int _V_offset = (m_iHeight - _iStringHeight) / 2;

        grf.DrawStringUtf8(m_strText.GetBuffer(), _H_offset, _V_offset, pFont);
    }

    if (m_do2gray)
    {
        grf.Do2Gray(0,0,m_iWidth, m_iHeight, 80, FALSE, (IsEnable() ? 0xff : 0x66));
    }

    DebugPrintf(DLC_CHENM, "UITouchButton::Draw()  End.");
    return hr;
}