πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by ! Tomasz Surma Tue, 17 Feb 1998 20:21
Wysrodkowanie bitmapy w oknie ...
#1616
Author: ! Tomasz Surma
Date: Tue, 17 Feb 1998 20:21
65 lines
3024 bytes
Witam,
  moje pytanie dotyczy wysrodkowania bitmapy.
  Zaczerpnalem fragment z przykladu SHOWDIB
  z funkcji OnDraw klasy widoku. Tu nalezaloby 
  dokonac zmian. Mysle ze potrzebne jest uzyskanie 
  aktualnego rozmiaru okna glownej ramy, i z jego
  pomoca i wymiarami bitmapy obliczyc wspolrzedne 
  jej umieszczenia. Ale nie wiem jak uzyskac rozmiar okna.

  Jak zmodyfikowac ponizszy fragment ?
  Dzieki za wszelka pomoc
           Tom

//=====================================================================
HDIB hDIB = pDoc->GetHDIB();
if (hDIB != NULL)
{
  LPSTR lpDIB = (LPSTR) ::GlobalLock((HGLOBAL) hDIB);
  int cxDIB = (int) ::DIBWidth(lpDIB); // Size of DIB - x
  int cyDIB = (int) ::DIBHeight(lpDIB); // Size of DIB - y
  ::GlobalUnlock((HGLOBAL) hDIB);

  CRect rcDIB;                           
  rcDIB.top = 0;                                  
  rcDIB.left = 0;
  rcDIB.right = cxDIB;            
  rcDIB.bottom = cyDIB;           
  CRect rcDest;                          
  if (pDC->IsPrinting())   // printer DC
   {
    // get size of printer page (in pixels)
    int cxPage = pDC->GetDeviceCaps(HORZRES);
    int cyPage = pDC->GetDeviceCaps(VERTRES);
    // get printer pixels per inch    
    int cxInch = pDC->GetDeviceCaps(LOGPIXELSX);
    int cyInch = pDC->GetDeviceCaps(LOGPIXELSY);
  
    // Best Fit case -- create a rectangle which preserves
    // the DIB's aspect ratio, and fills the page horizontally.
    //
    // The formula in the "->bottom" field below calculates the Y
    // position of the printed bitmap, based on the size of the
    // bitmap, the width of the page, and the relative size of
    // a printed pixel (cyInch / cxInch).
    //
    rcDest.top = rcDest.left = 0;
    rcDest.bottom = (int)(((double)cyDIB * cxPage * cyInch)
                    / ((double)cxDIB * cxInch));
    rcDest.right = cxPage;
   }
 else   // not printer DC
   {
    rcDest = rcDIB;
   }
 ::PaintDIB(pDC->m_hDC, &rcDest, pDoc->GetHDIB(),
 &rcDIB, pDoc->GetDocPalette());
}
//=====================================================================
-- 
__________________________________________________________
Tomasz Surma     ZACHODNIOPOMORSKA SZKOLA BUSINESSU
                                       (School of business    Szczecin)
**********************************************************
 WWW :                  http://www.eurnet.com/transword/tomtest  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: Wysrodkowanie bitmapy w oknie ...
#1617
Author: Michal Kaczmarczyk
Date: Wed, 18 Feb 1998 11:05
17 lines
1375 bytes
On Tue, 17 Feb 1998, ! Tomasz Surma wrote:

>   moje pytanie dotyczy wysrodkowania bitmapy.
>   Zaczerpnalem fragment z przykladu SHOWDIB
>   z funkcji OnDraw klasy widoku. Tu nalezaloby 
>   dokonac zmian. Mysle ze potrzebne jest uzyskanie 
>   aktualnego rozmiaru okna glownej ramy, i z jego
>   pomoca i wymiarami bitmapy obliczyc wspolrzedne 
>   jej umieszczenia. Ale nie wiem jak uzyskac rozmiar okna.

TRect GetClientRect() const;

Gets the coordinates of the window's client area (the area in a window you
can use for drawing).

_______________________________________________________________________________
MichaΕ‚ Kaczmarczyk  mailto:mik@iname.com http://student.uci.agh.edu.pl/~kaczmar
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads