Beispiel #1
0
void    TLDisplay::init(HWND hwnd, int x, int y, int w, int h, int percent)
{
	lockPickedGraph = false;
    percentH = percent;
    bmpX = x; bmpY = y;
    HDC hdc = GetDC(hwnd);
    bmpDC = CreateCompatibleDC(hdc);
    ReleaseDC(hwnd, hdc);
    DrawText(bmpDC,"9999", 4,&rtcode,DT_CALCRECT|DT_LEFT);
    TLDisplay::PixBlocW = rtcode.right;
    TLDisplay::TlineHalfH = rtcode.bottom/2 + 1;
    //
    //----> Font
    //
    hfont = CreateFont(
        -MulDiv(8, GetDeviceCaps(bmpDC, LOGPIXELSY), 72),	// logical height of font 
	    0,	// logical average character width 
	    0,	// angle of escapement 
	    0,	// base-line orientation angle 
	    FW_NORMAL,	// font weight FW_BOLD
	    FALSE,	// italic attribute flag 
	    FALSE,	// underline attribute flag 
	    FALSE,	// strikeout attribute flag 
	    DEFAULT_CHARSET,	// character set identifier 
	    OUT_TT_ONLY_PRECIS,	// output precision 
	    CLIP_DEFAULT_PRECIS,	// clipping precision 
	    PROOF_QUALITY,	// output quality 
	    DEFAULT_PITCH,	// pitch and family 
	    "Courrier"	// pointer to typeface name string 
       );
    ResizeBitmap(w, h);
}
void
wxMoColourPanel::OnSize( wxSizeEvent& event ) {

    //wxString s;
    //s.Printf( "w: %i", GetSize().GetWidth() );

    //wxMessageBox( s );

    if (  m_Pattern.GetWidth()!=event.GetSize().GetWidth() ||
          m_Pattern.GetHeight()!=event.GetSize().GetHeight() ) {

      #ifdef __WXMSW__
      m_Pattern.FreeResource();
      #endif

      if (!m_Pattern.Create( event.GetSize().GetWidth(), event.GetSize().GetHeight(), 24 )) {
        wxMessageBox(wxString("wxMoColourPanel error creating pattern bitmap."));
      }

      //SetSize( event );

      ResizeBitmap();
    }

    wxPanel::OnSize( event );

}
void
wxMoColourPanel::SetBitmap( const wxBitmap& bitmap ) {

  if (bitmap.IsOk()) {

      m_BitmapOriginal = bitmap;

      ResizeBitmap();

  }

  Refresh();

}
Beispiel #4
0
bool CExampleDemoDlg::GetFaceRect(Bitmap* pImageSori)
{
	//_sleep(100);
	Bitmap* pImageS = pImageSori->Clone(0, 0, pImageSori->GetWidth(), pImageSori->GetHeight(), PixelFormat32bppARGB);
	// TODO:  在此添加您专用的创建代码
	float scalew = 1.;
	if (pImageS->GetWidth() > 480 || pImageS->GetHeight() > 640)
	{

		scalew=min(480.f / pImageS->GetWidth(), 640.f / pImageS->GetHeight());

		int width = pImageS->GetWidth()*scalew;
		int height = pImageS->GetHeight()*scalew;
		ResizeBitmap(&pImageS, width, height);
	}


	Gdiplus::BitmapData TempBitmapData;
	Gdiplus::Rect rc(0, 0, pImageS->GetWidth(), pImageS->GetHeight());
	pImageS->LockBits(&rc, Gdiplus::ImageLockModeRead | Gdiplus::ImageLockModeWrite, PixelFormat32bppARGB, &TempBitmapData);


	CPupilGUI cpi = CPupilGUI((BYTE*)TempBitmapData.Scan0, TempBitmapData.Width, TempBitmapData.Height);
	pImageS->UnlockBits(&TempBitmapData);
	SAFE_DELETE(pImageS);
	if (cpi.isface == true)
	{
		int x0=cpi.m_face_detection.rFace.left;
		int y0 = cpi.m_face_detection.rFace.top;
		int width = (cpi.m_face_detection.rFace.right-x0)/scalew;
		int height = (cpi.m_face_detection.rFace.bottom-y0)/scalew;
		if (height+width<700)
		{
			return false;
		}
		else
		{
			return true;
		}
		//return GetRect(CRect(x0/scalew, y0/scalew, width/scalew, height/scalew), pImageSori);

	}
	else
	{
		return false;
	}



}
Beispiel #5
0
    SEA_EXPORT bool ConvertToGif(LPCWSTR szImagePath, LPCWSTR szGifPath, long width, long height)
    {
        Gdiplus::GpBitmap* pBitmap = nullptr;
        gdi_call(GdipLoadImageFromFile)(szImagePath, &pBitmap);

        if (!pBitmap)
            return false;

        if (width > 0 && height > 0)
        {
            Gdiplus::GpBitmap* pResized = ResizeBitmap(pBitmap, width, height);
            gdi_call(GdipDisposeImage)(pBitmap);
            pBitmap = pResized;
        }

        bool res = ConvertToGif(pBitmap, szGifPath);
        gdi_call(GdipDisposeImage)(pBitmap);
        return res;
    }
Beispiel #6
0
Bitmap* CExampleDemoDlg::GetRect(CRect r,Bitmap* pImageSori)
{
	int a = r.top + r.left;
	int b = r.Height();
	int c = r.Width();
	Gdiplus::BitmapData TempBitmapData_ori;
	Gdiplus::Rect rcori(0, 0, pImageSori->GetWidth(), pImageSori->GetHeight());
	pImageSori->LockBits(&rcori, Gdiplus::ImageLockModeRead | Gdiplus::ImageLockModeWrite, PixelFormat32bppARGB, &TempBitmapData_ori);
	BYTE*pori= (BYTE*)TempBitmapData_ori.Scan0;



	Bitmap* pImageS = pImageSori->Clone(0, 0, pImageSori->GetWidth(), pImageSori->GetHeight(), PixelFormat32bppARGB);
	ResizeBitmap(&pImageS, r.Width(), r.Height());
	Gdiplus::BitmapData TempBitmapData_scale;
	Gdiplus::Rect rcscale(0, 0, pImageS->GetWidth(), pImageS->GetHeight());
	pImageS->LockBits(&rcscale, Gdiplus::ImageLockModeRead | Gdiplus::ImageLockModeWrite, PixelFormat32bppARGB, &TempBitmapData_scale);
	BYTE*pscale = (BYTE*)TempBitmapData_scale.Scan0;

	for (int i=0;i<r.Height();i++)
	{
		for (int j = 0; j < r.Width(); j++)
		{
			int posx = r.left+ j;
			int posy = r.top + i;
			int indexori = (posy*TempBitmapData_ori.Width + posx) * 4;
			for (int k=0;k<4;k++)
			{
				pscale[(i*r.Width() + j) * 4+k] = pori[indexori+k];
			}

		}
	}
	pImageS->UnlockBits(&TempBitmapData_scale);
	pImageSori->UnlockBits(&TempBitmapData_ori);

	return  pImageS;
}
Beispiel #7
0
void PageRenderer::Start(CachedPage *page, int pageNo, int zoom, int rotation, thread_id *id, bool editAnnot) {
	// stop thread
	if (mRenderingThread != -1) {
		Abort();
		Wait();
	}

	mZoom = zoom;
	mPage = page;
	mEditAnnot = editAnnot;
	mPageNo = pageNo; mZoom = zoom; mRotate = rotation;

	GetSize(pageNo, &mWidth, &mHeight, mZoom);

	SetPDFPage(0, true, mWidth, mHeight);
#if 0
	if ((mPageMode == TWO_PAGES) && (pageNo + 1 <= mDoc->getNumPages())) {
		float width, height;
		GetSize(pageNo + 1, &width, &height);
		SetPDFPage(1, true, width, height);
		mWidth += width; mHeight = max_c(mHeight, height);
	} else {
		SetPDFPage(1, false, 0, 0);
	}
#endif
	ResizeBitmap(mWidth, mHeight);

	mPage->MakeEmpty();
	mPage->SetState(CachedPage::RENDERING);

	// start new thread
	mDoRendering = true;
	mRenderingThread = spawn_thread(page_rendering_thread, "page_rendering_thread", B_NORMAL_PRIORITY, this);
	*id = mRenderingThread;
	resume_thread(mRenderingThread);
}
Beispiel #8
0
bool wxWizard::ShowPage(wxWizardPage *page, bool goingForward)
{
    wxASSERT_MSG( page != m_page, wxT("this is useless") );

    wxSizerFlags flags(1);
    flags.Border(wxALL, m_border).Expand();

    if ( !m_started )
    {
        if ( m_usingSizer )
        {
            m_sizerBmpAndPage->Add(m_sizerPage, flags);

            // now that our layout is computed correctly, hide the pages
            // artificially shown in wxWizardSizer::Insert() back again
            m_sizerPage->HidePages();
        }
    }


    // remember the old bitmap (if any) to compare with the new one later
    wxBitmap bmpPrev;

    // check for previous page
    if ( m_page )
    {
        // send the event to the old page
        wxWizardEvent event(wxEVT_WIZARD_PAGE_CHANGING, GetId(),
                            goingForward, m_page);
        if ( m_page->GetEventHandler()->ProcessEvent(event) &&
             !event.IsAllowed() )
        {
            // vetoed by the page
            return false;
        }

        m_page->Hide();

        bmpPrev = m_page->GetBitmap();

        if ( !m_usingSizer )
            m_sizerBmpAndPage->Detach(m_page);
    }

    // set the new page
    m_page = page;

    // is this the end?
    if ( !m_page )
    {
        // terminate successfully
        if ( IsModal() )
        {
            EndModal(wxID_OK);
        }
        else
        {
            SetReturnCode(wxID_OK);
            Hide();
        }

        // and notify the user code (this is especially useful for modeless
        // wizards)
        wxWizardEvent event(wxEVT_WIZARD_FINISHED, GetId(), false, 0);
        (void)GetEventHandler()->ProcessEvent(event);

        return true;
    }

    // position and show the new page
    (void)m_page->TransferDataToWindow();

    if ( m_usingSizer )
    {
        // wxWizardSizer::RecalcSizes wants to be called when m_page changes
        m_sizerPage->RecalcSizes();
    }
    else // pages are not managed by the sizer
    {
        m_sizerBmpAndPage->Add(m_page, flags);
        m_sizerBmpAndPage->SetItemMinSize(m_page, GetPageSize());
    }

#if wxUSE_STATBMP
    // update the bitmap if:it changed
    wxBitmap bmp;
    if ( m_statbmp )
    {
        bmp = m_page->GetBitmap();
        if ( !bmp.Ok() )
            bmp = m_bitmap;

        if ( !bmpPrev.Ok() )
            bmpPrev = m_bitmap;

        if (!GetBitmapPlacement())
        {
            if ( !bmp.IsSameAs(bmpPrev) )
                m_statbmp->SetBitmap(bmp);
        }
    }
#endif // wxUSE_STATBMP


    // and update the buttons state
    m_btnPrev->Enable(HasPrevPage(m_page));

    const bool hasNext = HasNextPage(m_page);
    const wxString label = hasNext ? _("&Next >") : _("&Finish");
    if ( label != m_btnNext->GetLabel() )
        m_btnNext->SetLabel(label);

    m_btnNext->SetDefault();


    // send the change event to the new page now
    wxWizardEvent event(wxEVT_WIZARD_PAGE_CHANGED, GetId(), goingForward, m_page);
    (void)m_page->GetEventHandler()->ProcessEvent(event);

    // and finally show it
    m_page->Show();
    m_page->SetFocus();

    if ( !m_usingSizer )
        m_sizerBmpAndPage->Layout();

    if ( !m_started )
    {
        m_started = true;

        DoWizardLayout();
    }

    if (GetBitmapPlacement() && m_statbmp)
    {
        ResizeBitmap(bmp);

        if ( !bmp.IsSameAs(bmpPrev) )
            m_statbmp->SetBitmap(bmp);

        if (m_usingSizer)
            m_sizerPage->RecalcSizes();
    }

    return true;
}
Beispiel #9
0
void CCardio::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	m_YScale = bmpH/((m_YMax - m_YMin));
	ResizeBitmap(cx, cy);
}