Exemplo n.º 1
0
/*
-----------------------------------------------------------------------

-----------------------------------------------------------------------
*/
void CTraceContainer::Draw(const TRect& /*aRect*/) const
{
	CWindowGc& gc = SystemGc();
	
	if(iBgContext)
	{ 	
	  	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
		AknsDrawUtils::Background( skin, iBgContext, this, gc, Rect() );
	}
	
	TRect DrawRect(Rect());
	DrawRect.Shrink(2,2);
	gc.SetPenColor(KRgbBlack);
	gc.DrawLine(DrawRect.iTl,TPoint(DrawRect.iTl.iX,DrawRect.iBr.iY));
	gc.DrawLine(DrawRect.iTl,TPoint(DrawRect.iBr.iX,DrawRect.iTl.iY));
	gc.DrawLine(DrawRect.iBr,TPoint(DrawRect.iTl.iX,DrawRect.iBr.iY));
	gc.DrawLine(DrawRect.iBr,TPoint(DrawRect.iBr.iX,DrawRect.iTl.iY)); 
	
	DrawRect.Shrink(2,2);

	TInt HeightMe = (DrawRect.Height() / 2);
	
	TRect CpuRect(DrawRect.iTl.iX,DrawRect.iTl.iY,DrawRect.iBr.iX,(DrawRect.iTl.iY + (HeightMe - 1)));
	TRect MemRect(DrawRect.iTl.iX,(DrawRect.iTl.iY + (HeightMe + 1)),DrawRect.iBr.iX,DrawRect.iBr.iY);

	DrawCPU(CpuRect,gc);
	DrawMemory(MemRect,gc);
}
Exemplo n.º 2
0
int OSDDll::FormatAndDraw(CString text,	int iWidth,
                          int iHeight, BYTE *pBits2, CString pcolor,CString bcolor,int psize,CString pfont,int wi,int hi, bool han)
{
    TRACE("FormatAndDraw begin");
    //定义图形大小


    //定义图形大小
    DWORD NumColors=256;
    int iPixel  = 8;
    //图形格式参数
    LPBITMAPINFO lpbmih = new BITMAPINFO;
    lpbmih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    lpbmih->bmiHeader.biWidth = iWidth;
    lpbmih->bmiHeader.biHeight = iHeight;
    lpbmih->bmiHeader.biPlanes = 1;
    lpbmih->bmiHeader.biBitCount = iPixel;
    lpbmih->bmiHeader.biCompression = BI_RGB;
    lpbmih->bmiHeader.biSizeImage = iWidth*iHeight;
    lpbmih->bmiHeader.biXPelsPerMeter = 0;
    lpbmih->bmiHeader.biYPelsPerMeter = 0;
    lpbmih->bmiHeader.biClrUsed = 0;
    lpbmih->bmiHeader.biClrImportant = 0;

    //创建位图数据
    HDC hdc,hdcMem;
    HBITMAP hBitMap = NULL;
    CBitmap *pBitMap = NULL;
    CDC *pMemDC = NULL;
    BYTE *pBits;




    HPALETTE           hPalette=NULL;
    HBITMAP            hBitmap=NULL;
    HGLOBAL            hImgData=NULL;


    DWORD              ImgWidth=0 , ImgHeight=0;




    hdc = CreateIC(TEXT("DISPLAY"),NULL,NULL,NULL);


    hdcMem = CreateCompatibleDC(hdc);
    hBitMap = CreateDIBSection(hdcMem,lpbmih,DIB_PAL_COLORS,(void **)&pBits,NULL,0);
    pBitMap = new CBitmap;
    int kk=pBitMap->Attach(hBitMap);
    pMemDC = new CDC;
    int rr=pMemDC->Attach(hdcMem);
    class CBitmap * dd=pMemDC->SelectObject(pBitMap);





    //CRect rc(0,0,iWidth,iHeight);
    //pMemDC->SetBkMode(TRANSPARENT);

    //添加自绘图形
    DrawMemory(pMemDC,psize,text,1,1,1,pfont,han);

    int iBMPBytes = iWidth * iHeight * iPixel / 8;

    int ecolor=atoi(bcolor);
    int cc=atoi(pcolor);
    if (pBits==NULL) {
        for(int z=0; z<iBMPBytes; z++) {
            pBits2[z]=0x01;
        }
        TRACE("Error in CreateDIBSection and pMemDC");
        return -1;
    }
    //-------------bian kuang-------------
    for(int j=0; j<iHeight; j++) {
        for(int i=0; i<iWidth; i++) {
            int ss=i+j*iWidth;
            pBits2[ss]=pBits[(iHeight-j-1)*iWidth+i];
            //change color
            if (pBits2[ss]==0) {
                pBits2[ss]=0x01;
            } else {
                pBits2[ss]=cc;
            }
        }
    }

    if (wi!=0 && hi!=0) {
        for(j=0; j<iHeight; j++) {
            for(int i=0; i<iWidth; i++) {
                int temp=i+j*iWidth;
                if (i<wi && j< hi && pBits2[temp]!=cc) {
                    pBits2[temp]=ecolor;
                }
            }
        }
    }


    /*
    for(j=0;j<iHeight;j++){
    	for(int i=0;i<iWidth;i++){
    		int ss=i*j;
    		int tt=0;
    		if(pBits2[ss]==cc){
    			for (int k=-1;k<2;k++){
    				if (k==0) continue;
    				tt=ss+k;
    				if (tt<iBMPBytes && tt>-1 && pBits2[tt]!=cc){
    					pBits2[tt]=ecolor;
    				}
    				tt=ss+iWidth*k;
    				if (tt<iBMPBytes && tt>-1 && pBits2[tt]!=cc){
    					pBits2[tt]=ecolor;
    					tt++;
    					if (tt<iBMPBytes && tt>-1 && pBits2[tt]!=cc){
    						pBits2[tt]=ecolor;
    					}
    					tt--;
    					tt--;
    					if (tt<iBMPBytes && tt>-1 && pBits2[tt]!=cc){
    						pBits2[tt]=ecolor;
    					}
    				}
    			}
    		}
    	 }
    }*/

    pMemDC->DeleteDC();
    pBitMap->DeleteObject();
    //DeleteObject(hdcMem);

    delete pMemDC;
    pMemDC  = NULL;
    delete pBitMap;
    pBitMap = NULL;
    delete lpbmih;
    lpbmih  = NULL;
    TRACE("FormatAndDraw end");
    return 0;
}