Click here to Skip to main content
15,921,905 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Skins Pin
Rage19-Jul-02 2:02
professionalRage19-Jul-02 2:02 
GeneralMatrix memory allocation Pin
Rage19-Jul-02 1:25
professionalRage19-Jul-02 1:25 
GeneralRe: Matrix memory allocation Pin
Raphael Kindt19-Jul-02 1:34
Raphael Kindt19-Jul-02 1:34 
QuestionDisplay an image from a buffer ??? Pin
Raphael Kindt19-Jul-02 1:03
Raphael Kindt19-Jul-02 1:03 
AnswerRe: Display an image from a buffer ??? Pin
Chris Losinger19-Jul-02 3:37
professionalChris Losinger19-Jul-02 3:37 
GeneralRe: Display an image from a buffer ??? Pin
Raphael Kindt19-Jul-02 3:59
Raphael Kindt19-Jul-02 3:59 
GeneralRe: Display an image from a buffer ??? Pin
Chris Losinger19-Jul-02 4:00
professionalChris Losinger19-Jul-02 4:00 
GeneralRe: Display an image from a buffer ??? Pin
Raphael Kindt19-Jul-02 4:46
Raphael Kindt19-Jul-02 4:46 
For the moment I use some code and that works... but I don't find that very clean...

BITMAPINFO* m_pInfo; // is a member of the view
void CArchitectureView::SetBitmapInfoHeader()
{
   unsigned short max_shade = 256;
   m_pInfo = (BITMAPINFO *) malloc (sizeof(BITMAPINFOHEADER) + max_shade * sizeof(RGBQUAD));
   //Initialize the header of the DIB
   m_pInfo->bmiHeader.biBitCount = 8;
   m_pInfo->bmiHeader.biClrUsed = max_shade;		
   m_pInfo->bmiHeader.biSize= 40;
   m_pInfo->bmiHeader.biPlanes = 1;		//always = 1
   m_pInfo->bmiHeader.biCompression = BI_RGB;
   m_pInfo->bmiHeader.biSizeImage = 0;
   m_pInfo->bmiHeader.biXPelsPerMeter = m_pInfo->bmiHeader.biYPelsPerMeter = 0;
   m_pInfo->bmiHeader.biClrImportant = 0;
   m_pInfo->bmiHeader.biWidth = 0;
   m_pInfo->bmiHeader.biHeight = 0;

   //Initialize the color table of the DIB
   for(int i = 0; i < (int)m_pInfo->bmiHeader.biClrUsed; i++) {
      m_pInfo->bmiColors[i].rgbBlue = m_pInfo->bmiColors[i].rgbGreen = m_pInfo->bmiColors[i].rgbRed = i * (BYTE)(256 / m_pInfo->bmiHeader.biClrUsed);
      m_pInfo->bmiColors[i].rgbReserved = 0;
   }
}

I use this method during the Initialize of the view...
void CArchitectureView::OnInitialUpdate() 
{
   CView::OnInitialUpdate();
   if(m_pInfo == NULL)
      SetBitmapInfoHeader();
}

And the OnDraw() methods... pIm is a pointer to the image
void CArchitectureView::OnDraw(CDC* pDC)
{
   CArchitectureDoc* pDoc = GetDocument();
   ASSERT_VALID(pDoc);

   if(pDoc->ImAff == NULL)
      return;
   int H = pDoc->MyImList->GetImage(0).GetHeight();
   m_pInfo->bmiHeader.biWidth = pDoc->MyImList->GetImage(0).GetWidth();
   m_pInfo->bmiHeader.biHeight = -H;

   int mode = pDC->SetStretchBltMode(COLORONCOLOR);
   void* pIm = (void*)(pDoc->ImAff);

   StretchDIBits(pDC->GetSafeHdc(),
      0, 0, m_pInfo->bmiHeader.biWidth, H,
      0, 0, m_pInfo->bmiHeader.biWidth, H,
      pIm, m_pInfo, DIB_RGB_COLORS, SRCCOPY);

   pDC->SetStretchBltMode(mode);
}


yeap... It's clean???


Hello World!!! Smile | :)
from Raphaël
GeneralRe: Display an image from a buffer ??? Pin
Chris Losinger19-Jul-02 6:09
professionalChris Losinger19-Jul-02 6:09 
GeneralIPicture image output Pin
jalldridge18-Jul-02 23:52
jalldridge18-Jul-02 23:52 
GeneralVirtual List Box Pin
Anonymous18-Jul-02 23:43
Anonymous18-Jul-02 23:43 
GeneralRe: Virtual List Box Pin
Roger Allen18-Jul-02 23:58
Roger Allen18-Jul-02 23:58 
GeneralCArray trouble Pin
silverspoon18-Jul-02 23:36
silverspoon18-Jul-02 23:36 
GeneralRe: CArray trouble Pin
Martin Ziacek19-Jul-02 0:03
Martin Ziacek19-Jul-02 0:03 
GeneralRe: CArray trouble Pin
Alexandru Savescu19-Jul-02 0:09
Alexandru Savescu19-Jul-02 0:09 
GeneralRe: CArray trouble Pin
silverspoon19-Jul-02 0:22
silverspoon19-Jul-02 0:22 
GeneralRe: CArray trouble Pin
Christian Graus19-Jul-02 3:34
protectorChristian Graus19-Jul-02 3:34 
GeneralChange text in the status bar and tool tips Pin
Anonymous18-Jul-02 23:15
Anonymous18-Jul-02 23:15 
GeneralRe: Change text in the status bar and tool tips Pin
Roger Allen19-Jul-02 0:01
Roger Allen19-Jul-02 0:01 
GeneralRe: Change text in the status bar and tool tips Pin
Anonymous19-Jul-02 1:11
Anonymous19-Jul-02 1:11 
Questionhelp ! how to change drag icon ? Pin
includeh1018-Jul-02 22:46
includeh1018-Jul-02 22:46 
QuestionHow should i do that? Pin
chen18-Jul-02 22:41
chen18-Jul-02 22:41 
AnswerRe: How should i do that? Pin
Christian Graus19-Jul-02 3:36
protectorChristian Graus19-Jul-02 3:36 
GeneralRe: How should i do that? Pin
chen19-Jul-02 7:21
chen19-Jul-02 7:21 
GeneralRe: How should i do that? Pin
Christian Graus19-Jul-02 11:38
protectorChristian Graus19-Jul-02 11:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.