Пример #1
0
void RWindows::UpdateRect(const TRect& aRect,const TSize& aSize)
	{
	if (iOrientation & 1)
		SetDIBitsToDevice(iHdc,aRect.iTl.iX,aRect.iTl.iY,aRect.Width(),aRect.Height(),
		aRect.iTl.iX,aSize.iWidth-aRect.iBr.iY,0,aSize.iWidth,i90BitmapBits,
		((LPBITMAPINFO)i90BitmapInfo),DIB_RGB_COLORS);
	else
		SetDIBitsToDevice(iHdc,aRect.iTl.iX,aRect.iTl.iY,aRect.Width(),aRect.Height(),
		aRect.iTl.iX,aSize.iHeight-aRect.iBr.iY,0,aSize.iHeight,iBitmapBits,
		((LPBITMAPINFO)iBitmapInfo),DIB_RGB_COLORS);
	}
Пример #2
0
VOID Render()
{
	//render into buffer here

	HDC winDC=GetDC(hWnd);

	RECT r={0,HEIGHT,WIDTH,HEIGHT+200};
	FillRect(winDC,&r,(HBRUSH)GetStockObject(BLACK_BRUSH));

	SetDIBitsToDevice(
		winDC,
		0,0,WIDTH,HEIGHT,
		0,0,0,HEIGHT,
		buffer,
		&bmi,
		DIB_RGB_COLORS
);


	ReleaseDC(hWnd,winDC);

	/*frames++;
	
	int tickdiff=GetTickCount()-ticks;
	if(tickdiff>=1000)
	{
		static char m1[100];
		float fps=(frames*1000.0)/tickdiff;
		sprintf(m1,"%d frames rendered in %d ms = %1.3f fps.", frames,tickdiff,fps);
		SetWindowText(hWnd,m1);
		frames=0;
		ticks=GetTickCount();
	}*/
}
Пример #3
0
//---------------------------------------------------------------------
//
// Function:   DIBPaint
//
// Purpose:    Painting routine for a DIB.  Calls StretchDIBits() or
//             SetDIBitsToDevice() to paint the DIB.  The DIB is
//             output to the specified DC, at the coordinates given
//             in lpDCRect.  The area of the DIB to be output is
//             given by lpDIBRect.  The specified palette is used.
//
// Parms:      hDC       == DC to do output to.
//             lpDCRect  == Rectangle on DC to do output to.
//             hDIB      == Handle to global memory with a DIB spec
//                          in it (either a BITMAPINFO or BITMAPCOREINFO
//                          followed by the DIB bits).
//             lpDIBRect == Rect of DIB to output into lpDCRect.
//             hPal      == Palette to be used.
//
// History:   Date      Reason
//             6/01/91  Created
//
//---------------------------------------------------------------------
static void DIBPaint (HDC hDC,LPRECT lpDCRect,HANDLE hDIB)
{
   LPSTR    lpDIBHdr, lpDIBBits;

   if (!hDIB)
      return;
      // Lock down the DIB, and get a pointer to the beginning of the bit
      //  buffer.
        lpDIBHdr  = GlobalLock (hDIB);
        lpDIBBits = FindDIBBits (lpDIBHdr);
      // Make sure to use the stretching mode best for color pictures.
        SetStretchBltMode (hDC, COLORONCOLOR);
        SetDIBitsToDevice (hDC,                          // hDC
                         lpDCRect->left,               // DestX
                         lpDCRect->top,                // DestY
                         RECTWIDTH (lpDCRect),         // nDestWidth
                         RECTHEIGHT (lpDCRect),        // nDestHeight
                                                                 0,              // SrcX
                         0,
 //                        (int) DIBHeight (lpDIBHdr),   // SrcY
                                                                 0,                            // nStartScan
                         (WORD) DIBHeight (lpDIBHdr),  // nNumScans
                         lpDIBBits,                    // lpBits
                         (LPBITMAPINFO) lpDIBHdr,      // lpBitsInfo
                         DIB_RGB_COLORS);              // wUsage

   GlobalUnlock (hDIB);
}
Пример #4
0
void BitmapControl::OnDraw(CDC* dc)
{
  RECT r;
  GetClientRect(&r);
  int w1 = r.right - r.left;
  int h1 = r.bottom - r.top;
  CDC memDC;
  memDC.CreateCompatibleDC(dc);
  if(!stretch) {
    if(w > w1)
      w1 = w;
    if(h > h1)
      h1 = h;
  }
  CBitmap bitmap, *pOldBitmap;
  bitmap.CreateCompatibleBitmap(dc, w1, h1);
  pOldBitmap = memDC.SelectObject(&bitmap);
  if(stretch) {
    bmpInfo->bmiHeader.biWidth = w;
    bmpInfo->bmiHeader.biHeight = -h;

    StretchDIBits(memDC.GetSafeHdc(),
                  0,
                  0,
                  w1,
                  h1,
                  0,
                  0,
                  w,
                  h,
                  data,
                  bmpInfo,
                  DIB_RGB_COLORS,
                  SRCCOPY);
  } else {
    FillOutsideRect(&memDC, CBrush::FromHandle(GetSysColorBrush(COLOR_BTNFACE)));

    bmpInfo->bmiHeader.biWidth = w;
    bmpInfo->bmiHeader.biHeight = -h;
    SetDIBitsToDevice(memDC.GetSafeHdc(),
                      0,
                      0,
                      w,
                      h,
                      0,
                      0,
                      0,
                      h,
                      data,
                      bmpInfo,
                      DIB_RGB_COLORS);
  }

  dc->BitBlt(0,0,w1,h1,
             &memDC,0,0,SRCCOPY);
  memDC.SelectObject(pOldBitmap);

  bitmap.DeleteObject();
  memDC.DeleteDC();
}
Пример #5
0
void guiOpenDebug() {
	if (!g_hwndDebugWindow)
		g_hwndDebugWindow = CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_DEBUGVAL), NULL, DebugDlgProc);
#pragma vdpragma_TODO("improve this")
#ifndef _M_AMD64
	else if (GetKeyState(VK_CONTROL)<0) {
		char *p = new char[16384+128];
		static const struct {
			BITMAPINFOHEADER bih;
			unsigned long p[8];
		} f={
			{sizeof(BITMAPINFOHEADER),128,128,1,8,BI_RGB,128*128,0,0,0,0},
			{
				0xffffff,
				0xf1f1f1,
				0xdfdfdf,
				0xc9c9c9,
				0xafafaf,
				0x919191,
				0x6d6d6d,
				0x404040,
			}
		};
		ycblit(p,0);

		HDC hdc = GetDC(g_hWnd);
		SetDIBitsToDevice(hdc, 0, 0, 128, 128, 0, 0, 0, 128, p, (const BITMAPINFO *)&f.bih, DIB_RGB_COLORS);
		ReleaseDC(g_hWnd, hdc);

		delete[] p;
	}
#endif
}
Пример #6
0
BOOL sw_SwapBuffers(HDC hdc, struct wgl_dc_data* dc_data)
{
    struct sw_framebuffer* fb = dc_data->sw_data;
    struct sw_context* sw_ctx = (struct sw_context*)IntGetCurrentDHGLRC();
    
    /* Notify mesa */
    if(sw_ctx)
        _mesa_notifySwapBuffers(&sw_ctx->mesa);
    
    if(!(fb->flags & SW_FB_DOUBLEBUFFERED))
        return TRUE;

    /* Upload to the display */
    return (SetDIBitsToDevice(hdc,
        0,
        0,
        fb->bmi.bmiHeader.biWidth,
        fb->bmi.bmiHeader.biHeight,
        0,
        0,
        0,
        fb->bmi.bmiHeader.biHeight,
        fb->backbuffer.Buffer,
        &fb->bmi,
        DIB_RGB_COLORS) != 0);
}
Пример #7
0
void XYDrawbox::DisplayImage(HDC& hdc)
{
	BITMAPINFO bmi;
	
	if (this->pimgdata == NULL)
	{
		std::cout << ":D:" << "IMGDATA==NULL" << std::endl;
		return;
	}
	else
	{
		ZeroMemory(&bmi, sizeof(BITMAPINFO));
		bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
		bmi.bmiHeader.biWidth = this->lengthXScroll;
		bmi.bmiHeader.biHeight = this->lengthYScroll;
		bmi.bmiHeader.biPlanes = 1;
		bmi.bmiHeader.biBitCount = 32;
		bmi.bmiHeader.biCompression = BI_RGB;
		SetDIBitsToDevice(hdc,
			0, 0, this->lengthXScroll, this->lengthYScroll,
			this->posXScroll, 0,
			this->posYScroll, this->lengthYScroll,
			this->pimgdata,
			&bmi,
			DIB_RGB_COLORS
			);
	}
}
Пример #8
0
void Canvas::redraw() {
  PAINTSTRUCT ps;
  BeginPaint(widget->window, &ps);
  SetDIBitsToDevice(ps.hdc, 0, 0, canvas->width, canvas->height, 0, 0, 0, canvas->height, (void*)canvas->buffer, &canvas->bmi, DIB_RGB_COLORS);
  EndPaint(widget->window, &ps);
  InvalidateRect(widget->window, 0, false);
}
Пример #9
0
void window_render_gdi::render_end()
{
	BITMAPINFO bmi;
	ZeroMemory(&bmi,sizeof(bmi));
	BITMAPINFOHEADER& h = bmi.bmiHeader;
	h.biSize = sizeof(BITMAPINFOHEADER);
	h.biWidth = m_image->m_width;
	h.biHeight = -m_image->m_height;
	h.biPlanes = 1;
	h.biBitCount = 24;
	h.biCompression = BI_RGB;
	h.biSizeImage = m_image->m_width * m_image->m_height;

	//flip();
	HDC dc = GetDC((HWND)m_window->m_hWnd);
	m_image->rgb2bgr();
	int err = SetDIBitsToDevice(dc,0,0,m_image->m_width,m_image->m_height,
		0,0,0,m_image->m_height,
		m_image->get_buffer() ,
		&bmi,
		DIB_RGB_COLORS);
	if (err <= 0)
	{
		//GDI_ERROR
		printf("error! SetDIBitsToDevice %d %d\n",err,GetLastError());
	}
	ReleaseDC((HWND)m_window->m_hWnd,dc);
	window_render::render_end();
}
Пример #10
0
static void winblit(RECT r)
{
    int x0 = r.left;
    int y0 = r.top;
    int x1 = r.right;
    int y1 = r.bottom;

    dibinf->bmiHeader.biWidth = gli_image_w;
    dibinf->bmiHeader.biHeight = -gli_image_h;
    dibinf->bmiHeader.biSizeImage = gli_image_h * gli_image_s;

    SetDIBitsToDevice(hdc,
        x0, /* destx */
        y0, /* desty */
        x1 - x0, /* destw */
        y1 - y0, /* desth */
        x0, /* srcx */
        gli_image_h - y1, /* srcy */
        0, /* startscan */
        gli_image_h, /* numscans */
        gli_image_rgb, /* pBits */
        dibinf, /* pInfo */
        DIB_RGB_COLORS /* color use flag */
             );
}
Пример #11
0
void redraw(HWND hwnd, HDC dc)
{
    DWORD t1, t2;
    char s[2000];

    unsigned ASX = align(SX);

    if (!image_valid) {
        alloc_data();
        t1 = GetTickCount ();
        calculate_multi();
        t2 = GetTickCount();
        sprintf (s, "Mandelbrot Set %s; Image: %d x %d; (%f, %f, d=%g) time: %d ms; %d cores; %5.1f FPS%s", method_names [func_index], ASX, SY,
            X0, Y0, scale,
            (t2 - t1),
            processor_count,
            1000.0 / (t2 - t1),
            full_mode ? "; ALL MODES" : "");
        SetWindowText(hwnd, s);
        image_valid = TRUE;
    }
    bi.h.biWidth = ASX;
    bi.h.biHeight = -(LONG)SY;
    SetDIBitsToDevice(dc, 0, 0, ASX, SY, 0, 0, 0, SY, data, (BITMAPINFO*)&bi, DIB_RGB_COLORS);
}
Пример #12
0
/****************************************************************************
*
*     FUNCTION: DrawXORMask
*
*     PURPOSE:  Using DIB functions, draw XOR mask on hDC in Rect
*
*     PARAMS:   HDC         hDC    - The DC on which to draw
*               RECT        Rect   - Bounding rect for drawing area
*               LPICONIMAGE lpIcon - pointer to icon image data
*
*     RETURNS:  BOOL - TRUE for success, FALSE for failure
*
*     COMMENTS: Does not use any palette information since the
*               OS won't when it draws the icon anyway.
*
* History:
*                July '95 - Created
*
\****************************************************************************/
BOOL DrawXORMask( HDC hDC, RECT Rect, LPICONIMAGE lpIcon )
{
    int            	x, y;

    // Sanity checks
    if( lpIcon == NULL )
        return FALSE;
    if( lpIcon->lpBits == NULL )
        return FALSE;

    // Account for height*2 thing
    lpIcon->lpbi->bmiHeader.biHeight /= 2;

    // Locate it
    x = Rect.left + ((RectWidth(Rect)-lpIcon->lpbi->bmiHeader.biWidth)/2);
    y = Rect.top + ((RectHeight(Rect)-lpIcon->lpbi->bmiHeader.biHeight)/2);

    // Blast it to the screen
    SetDIBitsToDevice( hDC, x, y, lpIcon->lpbi->bmiHeader.biWidth, lpIcon->lpbi->bmiHeader.biHeight, 0, 0, 0, lpIcon->lpbi->bmiHeader.biHeight, lpIcon->lpXOR, lpIcon->lpbi, DIB_RGB_COLORS );

    // UnAccount for height*2 thing
    lpIcon->lpbi->bmiHeader.biHeight *= 2;

    return TRUE;
}
Пример #13
0
void ViewPort::ImageToViewDC( void )			// copies the already rendered view to DC
{
	if ( view->bmi && viewDC )						// do only if have necessary ingredients
		SetDIBitsToDevice( viewDC, 0, 0, view->width, view->height,
								0, 0, 0, view->height, view->bits,
								view->bmi, DIB_RGB_COLORS );
}
Пример #14
0
void					
Bitmap::copyPixelsToDevice(
	HDC					aTargetDc,
	int					aXDest,		// = 0
	int					aYDest,		// = 0
	int					aHeight,	// = 0
	int					aWidth,		// = 0
	int					aXSrc,		// = 0
	int					aYSrc)		// = 0	
{
	if (aHeight == 0) {
		aHeight = myHeight;
	}
	if (aWidth == 0) {
		aWidth = myWidth;
	}

    SelectObject(aTargetDc, myBmp); // assign the dib section to the dc

	SetDIBitsToDevice(	aTargetDc, 
						aXDest, 
						aYDest, 
						aWidth, 
						aHeight, 
						aXSrc, 
						aYSrc, 
						0, 
						myHeight, 
						&myPixels[0], 
						&myBitmapInfo, 
						DIB_RGB_COLORS);
}
Пример #15
0
	void GDIRenderTarget::Flip()
	{
		RECT client;
		HDC hDC;
		Color *FrontVPData;
		unsigned int *DIBData;
	
		Color BufferOneColor(100, 149, 237,0);
		Color BufferTwoColor(100, 149, 237,0);

		//set up pointers to destination and source
		if(m_CurrentBackBuffer == m_VPage1)
		{
			FrontVPData = m_VPage1; //Set m_VPage1 as frontbuffer we want to present.
			m_CurrentBackBuffer = m_VPage2; //Set m_VPage2 as backbuffer.
			//memset(m_VPage2,0,(sizeof(Color) * m_frameBufferLength));
			SetFrameBufferColor(BufferTwoColor,2); //Set the color of m_vPage2
			m_CurrentZbuffer = m_ZBuffer2;
			memset(m_ZBuffer2,0,(sizeof(float) * m_frameBufferLength)); //Clean ZBuffer2
		}
		else
		{
			FrontVPData = m_VPage2; //Set m_VPage2 as frontBuffer we want to present.
			m_CurrentBackBuffer = m_VPage1; //Set m_vPage2 as backbuffer
			//memset(m_VPage1,0,(sizeof(Color) * m_frameBufferLength));
			SetFrameBufferColor(BufferOneColor,1); //Set the color of m_vPage1 
			m_CurrentZbuffer = m_ZBuffer1; 
			memset(m_ZBuffer1,0,(sizeof(float) * m_frameBufferLength)); //Clean ZBuffer1
		}
	
		DIBData = (unsigned int*)FrontVPData;

		//Get the windows device context
		hDC = GetDC(*(m_hWindow));
	
		//If it's available
		if(hDC != NULL)
		{
			//Get the window dimensions 
			GetClientRect(*(m_hWindow),&client);

			SetDIBitsToDevice(
				hDC,
				client.left,
				client.top,
				m_width,
				m_height,
				0,
				0,
				0,
				m_height,
				DIBData,
				&m_bitmapInfo,
				DIB_RGB_COLORS);
		
			//release the device context.
			ReleaseDC(*(m_hWindow),hDC);
		}
		//Reset background
	}
Пример #16
0
void CChildView::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	CPen Pen;
	Pen.CreatePen(PS_SOLID, 1, RGB(0,0,255));
	CPen *pOldPen;
	pOldPen = dc.SelectObject(&Pen);

	CBrush Brush;
	Brush.CreateSolidBrush(RGB(0,255,0));
	CBrush *pOldBrush = dc.SelectObject(&Brush);
	{
		dc.MoveTo(0,0);
		dc.LineTo(100,100);
		dc.Rectangle(100,100,200,200);
	}
	dc.SelectObject(pOldPen);
	dc.SelectObject(pOldBrush);
	
	Brush.DeleteObject();
	Pen.DeleteObject();
	
	if(dibData == NULL)
		return;

	 SetDIBitsToDevice(dc.m_hDC,
     0, 0, imageWidth, imageHeight,   
     0, 0, 0, imageHeight,            
     dstData, bitmapInfo, DIB_RGB_COLORS);	
}
Пример #17
0
// --------------
// I_FinishUpdate
// --------------
void I_FinishUpdate(void)
{
    if (rendermode == render_none)
        return;

    if (I_SkipFrame())
        return;

    // display a graph of ticrate
    if (cv_ticrate.value)
        displayticrate(cv_ticrate.value);

    //
    if (bDIBMode)
    {
        // paranoia
        if (!hDCMain || !bmiMain || !vid.buffer)
            return;
        // main game loop, still in a window (-win parm)
        SetDIBitsToDevice(hDCMain, 0, 0, vid.width, vid.height, 0, 0, 0, vid.height, vid.buffer, bmiMain,
                          DIB_RGB_COLORS);
    }
    else
#ifdef HWRENDER
        if (rendermode != render_soft)
            HWD.pfnFinishUpdate(cv_vidwait.value);
        else
#endif
        {
            // DIRECT DRAW
            // copy virtual screen to real screen
            // can fail when not active (alt-tab)
            if (LockScreen())
            {
                /// \todo use directX blit here!!? a blit might use hardware with access
                /// to main memory on recent hardware, and software blit of directX may be
                /// optimized for p2 or mmx??
                if (ScreenHeight > vid.height)
                {
                    UINT8 *ptr = (UINT8 *)ScreenPtr;
                    size_t half_excess = ScreenPitch*(ScreenHeight-vid.height)/2;
                    memset(ptr, 0x1F, half_excess);
                    ptr += half_excess;
                    VID_BlitLinearScreen(screens[0], ptr, vid.width*vid.bpp, vid.height,
                                         vid.width*vid.bpp, ScreenPitch);
                    ptr += vid.height*ScreenPitch;
                    memset(ptr, 0x1F, half_excess);
                }
                else
                    VID_BlitLinearScreen(screens[0], (UINT8 *)ScreenPtr, vid.width*vid.bpp, vid.height,
                                         vid.width*vid.bpp, ScreenPitch);

                UnlockScreen();

                // swap screens
                ScreenFlip(cv_vidwait.value);
            }
        }
}
Пример #18
0
// CPhotoPubView 绘制
void CPhotoPubView::DrawImage(CDC *pDC,IplImage *pImg)
{
	int wid=0,hi=0;

	CRect ClipBox;
	GetClientRect(&ClipBox);
	if (!pImg) {
		CBitmap bkg;
		bkg.LoadBitmap(IDB_BACKGROUND);
		CBrush brush(&bkg);
		pDC->FillRect(&ClipBox,&brush);	
		return;
	}

	wid=int(pImg->width*m_ratio);
	hi=int(pImg->height*m_ratio);

	IplImage *pStub=pImg;
	IplImage *pTmp=NULL;
	if (wid!=pImg->width) {
		pTmp=cvCreateImage(cvSize(wid,hi),IPL_DEPTH_8U,3);
		cvResize(pImg,pTmp);
		pStub=pTmp;
	}
		

	CRgn WindowRgn;
	WindowRgn.CreateRectRgnIndirect(&ClipBox);
	CRect ImageRect(0,0,wid,hi);
	int top=max((ClipBox.Height()-hi)/2,0);
	int left=max((ClipBox.Width()-wid)/2,0);
	ImageRect.MoveToXY(left,top);
	CRgn ImageRgn;
	ImageRgn.CreateRectRgnIndirect(&ImageRect);
	WindowRgn.CombineRgn(&WindowRgn,&ImageRgn,RGN_DIFF);

	CBitmap bkg;
	bkg.LoadBitmap(IDB_BACKGROUND);
	CBrush brush(&bkg);
	pDC->FillRgn(&WindowRgn,&brush);	
	
	memset(m_bmih_buffer, 0, sizeof(*m_bmih_buffer));
    m_bmih_buffer->biSize = sizeof(BITMAPINFOHEADER);
    m_bmih_buffer->biWidth = wid;
    m_bmih_buffer->biHeight = -hi;
    m_bmih_buffer->biPlanes = 1;
    m_bmih_buffer->biBitCount = 24;
    m_bmih_buffer->biCompression = BI_RGB;


	SetDIBitsToDevice(
		pDC->m_hDC, 
		ImageRect.left,ImageRect.top,pStub->width,pStub->height, 
		0, 0, 0, hi, pStub->imageData, m_bmi_buffer, DIB_RGB_COLORS 
	);

	cvReleaseImage(&pTmp);

}
Пример #19
0
void CDemo_ClipView_VCDlg::OnBnClickedBtnClip() {
	BeginTimeAndMemoryMonitor2();
	clipTask.performClip();
	HDC hdc = cacheDC->GetSafeHdc();
	auto bitmapInfoHeader = clipTask.memoryBitmap_.BitmapInfoHeader();
	auto err = SetDIBitsToDevice(hdc, 0, 0, 800, 600, 0, 0, 0, 600, clipTask.memoryBitmap_.Data(), (BITMAPINFO*)&bitmapInfoHeader, DIB_RGB_COLORS);
	EndTimeAndMemoryMonitor2();
}
Пример #20
0
VOID CBufView::RenderOnDevice(HDC hDC)
{
	RECT rc = { 0 };
	if ( OnMessage(BVM_GETUPDATEAREA, 0, (LPARAM) &rc) )
		BitBlt(hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, m_buffer.hDC, rc.left, rc.top, SRCCOPY);
	else
		SetDIBitsToDevice(hDC, 0, 0, m_cs.cx, m_cs.cy, 0, 0, 0, m_cs.cy, m_buffer.pvBits, &m_buffer.bmi, DIB_RGB_COLORS);
}
void winblit()
{
    int x0 = gapp.panx;
    int y0 = gapp.pany;
    int x1 = gapp.panx + gapp.image->w;
    int y1 = gapp.pany + gapp.image->h;
    RECT r;

    if (bmpdata)
    {
	if (gapp.iscopying || justcopied)
	    invertcopyrect();

	dibinf->bmiHeader.biWidth = gapp.image->w;
	dibinf->bmiHeader.biHeight = -gapp.image->h;
	dibinf->bmiHeader.biSizeImage = gapp.image->h * bmpstride;
	SetDIBitsToDevice(hdc,
		gapp.panx, /* destx */
		gapp.pany, /* desty */
		gapp.image->w, /* destw */
		gapp.image->h, /* desth */
		0, /* srcx */
		0, /* srcy */
		0, /* startscan */
		gapp.image->h, /* numscans */
		bmpdata, /* pBits */
		dibinf, /* pInfo */
		DIB_RGB_COLORS /* color use flag */
			 );

	if (gapp.iscopying || justcopied)
	    invertcopyrect();
    }

    /* Grey background */
    r.top = 0; r.bottom = gapp.winh;
    r.left = 0; r.right = x0;
    FillRect(hdc, &r, bgbrush);
    r.left = x1; r.right = gapp.winw;
    FillRect(hdc, &r, bgbrush);
    r.left = 0; r.right = gapp.winw;
    r.top = 0; r.bottom = y0;
    FillRect(hdc, &r, bgbrush);
    r.top = y1; r.bottom = gapp.winh;
    FillRect(hdc, &r, bgbrush);

    /* Drop shadow */
    r.left = x0 + 2;
    r.right = x1 + 2;
    r.top = y1;
    r.bottom = y1 + 2;
    FillRect(hdc, &r, shbrush);
    r.left = x1;
    r.right = x1 + 2;
    r.top = y0 + 2;
    r.bottom = y1;
    FillRect(hdc, &r, shbrush);
}
Пример #22
0
void CTCSys::QSSysDisplayImage()
{
	SetDIBitsToDevice(ImageDC[0]->GetSafeHdc(), 1, 1,
		m_bitmapInfo.bmiHeader.biWidth,
		::abs(m_bitmapInfo.bmiHeader.biHeight),
		0, 0, 0,
		::abs(m_bitmapInfo.bmiHeader.biHeight),
		IR.DispBuf[0].data,
		&m_bitmapInfo, DIB_RGB_COLORS);
}
Пример #23
0
void SoftwareGraphicsDevice::FinishRender(WindowObjects &O, AppInterface &App)
{
    UINT Width = O.GetWindowManager().GetWidth();
    UINT Height = O.GetWindowManager().GetHeight();
    Info.bmiHeader.biWidth = Width;
    Info.bmiHeader.biHeight = Height;

    //load Bmp into our window (represented by hDC)
    SetDIBitsToDevice(hDC, 0, 0, Width, Height, 0, 0, 0, Height, &Bmp[0][0], &Info, DIB_RGB_COLORS);
}
Пример #24
0
int fbx_write(fbx_struct *fb, int srcX_, int srcY_, int dstX_, int dstY_,
	int width_, int height_)
{
	int srcX, srcY, dstX, dstY, width, height;
	#ifdef _WIN32
	BITMAPINFO bmi;  fbx_gc gc;
	#endif

	if(!fb) _throw("Invalid argument");

	srcX=srcX_>=0? srcX_:0;  srcY=srcY_>=0? srcY_:0;
	dstX=dstX_>=0? dstX_:0;  dstY=dstY_>=0? dstY_:0;
	width=width_>0? width_:fb->width;
	height=height_>0? height_:fb->height;

	if(width>fb->width) width=fb->width;
	if(height>fb->height) height=fb->height;
	if(srcX+width>fb->width) width=fb->width-srcX;
	if(srcY+height>fb->height) height=fb->height-srcY;

	#ifdef _WIN32

	if(!fb->wh || fb->width<=0 || fb->height<=0 || !fb->bits)
		_throw("Not initialized");
	memset(&bmi, 0, sizeof(bmi));
	bmi.bmiHeader.biSize=sizeof(bmi);
	bmi.bmiHeader.biWidth=fb->width;
	bmi.bmiHeader.biHeight=-fb->height;
	bmi.bmiHeader.biPlanes=1;
	bmi.bmiHeader.biBitCount=fbx_ps[fb->format]*8;
	bmi.bmiHeader.biCompression=BI_RGB;
	_w32(gc=GetDC(fb->wh));
	_w32(SetDIBitsToDevice(gc, dstX, dstY, width, height, srcX, 0, 0, height,
		&fb->bits[srcY*fb->pitch], &bmi, DIB_RGB_COLORS));
	_w32(ReleaseDC(fb->wh, gc));
	return 0;

	#else

	if(!fb->pm || !fb->shm)
		if(fbx_awrite(fb, srcX, srcY, dstX, dstY, width, height)==-1) return -1;
	if(fb->pm)
	{
		XCopyArea(fb->wh.dpy, fb->pm, fb->wh.d, fb->xgc, srcX, srcY, width,
			height, dstX, dstY);
	}
	XFlush(fb->wh.dpy);
	XSync(fb->wh.dpy, False);
	return 0;

	#endif

	finally:
	return -1;
}
Пример #25
0
static void gdiRefreshBitmap(HDC hdc, int x, int y, int width, int height,
                             int dx, int dy) {
    if (gb.hdcMem == NULL) {
        gb.bi.bmiHeader.biSize          = sizeof(gb.bi.bmiHeader);
        gb.bi.bmiHeader.biWidth         = CHAM_WIDTH;
        gb.bi.bmiHeader.biHeight        = -CHAM_HEIGHT;
        gb.bi.bmiHeader.biPlanes        = 1;
        gb.bi.bmiHeader.biBitCount      = sizeof (long) * 8;
        gb.bi.bmiHeader.biCompression   = BI_RGB;
        gb.bi.bmiHeader.biSizeImage     = width * height * sizeof (long);
        gb.bi.bmiHeader.biXPelsPerMeter = 0;
        gb.bi.bmiHeader.biYPelsPerMeter = 0;
        gb.bi.bmiHeader.biClrUsed       = 0;
        gb.bi.bmiHeader.biClrImportant  = 0;

        gb.hdcMem = CreateCompatibleDC(hdc);
        gb.destHBmp = CreateDIBSection(gb.hdcMem, &gb.bi, DIB_RGB_COLORS,
                                       (void**)(&gb.destBits), NULL, 0);

        if (gb.destBits != NULL) {
            gb.oobj = SelectObject(gb.hdcMem, gb.destHBmp);
            SelectObject(gb.hdcMem, gb.oobj);
        }
        x = 0;
        y = 0;
        width = CHAM_WIDTH;
        height = CHAM_HEIGHT;
    }

    gxj_pixel_type* pixels = gxj_system_screen_buffer.pixelData;
    int i, j;

    for (j = 0; j < height; j++) {
        pixels = &gxj_system_screen_buffer.pixelData[(y + j) * CHAM_WIDTH + x];
        unsigned char *destPtr =
            gb.destBits + (((y + j) * CHAM_WIDTH + x) * sizeof(long));

        for (i = 0; i < width; i++) {
            gxj_pixel_type pixel = *pixels++;
            int r = GXJ_GET_RED_FROM_PIXEL(pixel);
            int g = GXJ_GET_GREEN_FROM_PIXEL(pixel);
            int b = GXJ_GET_BLUE_FROM_PIXEL(pixel);

            *destPtr++ = b; /* dest pixels is to be in BGRA order */
            *destPtr++ = g;
            *destPtr++ = r;
             destPtr++;
        }
    }

    /* IMPL_NOTE: don't need to copy the entire screen */
    SetDIBitsToDevice(hdc, dx, dy, CHAM_WIDTH, CHAM_HEIGHT, 0, 0, 0,
                      CHAM_HEIGHT, gb.destBits, &gb.bi, DIB_RGB_COLORS);
}
Пример #26
0
void CRScrlBarCtrl::DrawTiledBitmap(FileNum filenum,CDC* pdc,int x,int y,int length)
{
	if (m_hWnd)
	{
		CWnd* parent;
		if (m_parent)
			parent=m_parent;
		else
			parent=GetParent()->GetParent();
		BYTE* pData;
		pData = (BYTE*)parent->SendMessage(WM_GETFILE,filenum,NULL);
		if (pData && pData[0]=='B' && pData[1]=='M') // checks if its a bitmap file
		{
			// now render it...
			BITMAPFILEHEADER* pFile=(BITMAPFILEHEADER*)pData;
			BITMAPINFO* pInfo=(BITMAPINFO*)(pData+sizeof(BITMAPFILEHEADER));
			pData+=pFile->bfOffBits;
			// tiling...
			int z,width;
			if (m_bHorzAlign)
			{
				for (z=x;z<x+length;z+=pInfo->bmiHeader.biWidth)
				{
					width=min(x+length-z,pInfo->bmiHeader.biWidth);
					SetDIBitsToDevice(pdc->m_hDC,z,y,width, pInfo->bmiHeader.biHeight,
						0,0,0,pInfo->bmiHeader.biHeight,pData,pInfo,DIB_RGB_COLORS);
				}
			}
			else
			{
				for (z=y;z<y+length;z+=pInfo->bmiHeader.biHeight)
				{
					width=min(y+length-z,pInfo->bmiHeader.biHeight);
					SetDIBitsToDevice(pdc->m_hDC,x,z, pInfo->bmiHeader.biWidth, width,
						0,0,0,pInfo->bmiHeader.biHeight,pData,pInfo,DIB_RGB_COLORS);
				}
			}
		}
		parent->SendMessage(WM_RELEASELASTFILE,NULL,NULL);
	}
}
Пример #27
0
LRESULT WINAPI Window::window_proc(
    HWND                window,
    UINT                message,
    WPARAM              wparam,
    LPARAM              lparam) {
    
    Window* this_window = (Window*)GetWindowLong(window, GWL_USERDATA);
    
    switch (message) {
    case WM_KEYDOWN:
        PostQuitMessage(0);
        return 0;

    /*    case WM_KEYDOWN:
    this_window->keyChange(wparam, true);
    return 0;
    
      case WM_KEYUP:
      this_window->keyChange(wparam, false);
      return 0;  
        */
    case WM_CLOSE:
        PostQuitMessage(0);
        return 0;
        
    case WM_DESTROY:
        this_window->window = NULL;
        break;
        
    case WM_PAINT:
        SetDIBitsToDevice(
            this_window->hDC,
            0, 
            0,
            this_window->width,
            this_window->height,   // source rectangle height
            0,        // x-coordinate of lower-left corner of source rect.
            0,        // y-coordinate of lower-left corner of source rect.
            0,        // first scan line in array
            this_window->height,   // number of scan lines
            this_window->buffer,
            &(this_window->bitmap_info),
            DIB_RGB_COLORS);  
        break;
        
    case BLIT_BUFFER:
        //this_window->redraw();
        break;
    }
    
    return DefWindowProc(window, message, wparam, lparam);    

}
Пример #28
0
Файл: api.c Проект: ifbe/tool
void writescreen()
{
	//int result=SetDIBitsToDevice(realdc,
	SetDIBitsToDevice(realdc,
			0,0,		//目标位置x,y
			width,height,		//dib宽,高
			0,0,		//来源起始x,y
			0,height,			//起始扫描线,数组中扫描线数量,
			mypixel,		//rbg颜色数组
			&info,			//bitmapinfo
			DIB_RGB_COLORS);		//颜色格式
	//printf("result:%x\n",result);
}
Пример #29
0
void sBlit2D(const sU32 *data,sInt width,const sRect &dest)
{
  BITMAPINFO bmi;
  sClear(bmi);

  bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
  bmi.bmiHeader.biWidth = width;
  bmi.bmiHeader.biHeight = -dest.SizeY();
  bmi.bmiHeader.biPlanes = 1;
  bmi.bmiHeader.biBitCount = 32;
  bmi.bmiHeader.biCompression = BI_RGB;
  SetDIBitsToDevice(sGDIDC,dest.x0,dest.y0,dest.SizeX(),dest.SizeY(),0,0,0,dest.SizeY(),data,&bmi,DIB_RGB_COLORS);
}
Пример #30
0
void DVV::flush_buf_b1(HDC hdc)
{
	SetDIBitsToDevice
	(
		hdc, 
		_last_x0,_last_y, // x,y dans cible
		(DWORD)(_last_x-_last_x0),(DWORD) (1), // larg-haut 
		_last_x0,0,          // dans src
		0, (UINT)_tyB, 
		_im, _bmi, 
		(UINT) DIB_RGB_COLORS
	);
}