An enhanced DIBLOOK sample

This article describes a sample with the same funcionality as the known DIBLOOK MFC sample, but enhanced in some ways. The main (new) features of this new sample are:

  • The sample is now completely object oriented, there are no global functions
  • The standard file open dialog has been changed to a new (derived from standard) file dialog with preview
  • The palette treatment has been improved so the palette is not realized twice for the active image (the first in foregroud the second in background)

The sample also demonstrates some programming techniques:

  • Changing the standard file open in doc/view MFC architecture
  • Modifiyng standard dialogs without using new hook functions (or what's the same: using the MFC hook functions)
  • Correct palette treatment
  • Subclassing controls

Several new classes were added to the original DIBLOOK sample:

  • The dib api provided as a set of global functions was encapsulated in a CDib class (described in an article in the bitmaps & palettes section)
  • A static control descendant that displays an image (described in an article in the static control section)
  • A descendant from CFileDialog to implement the file open dialog with preview (described in an article in the dialogs section)
  • A descendant from CDocManager needed to change the default MFC file open dialog (described in an article in the doc-view section)

Download Source Code


Last updated: 25 June 1998



Comments

  • How to include provision displaying TIFF,WMF (Urgent).....

    Posted by Legacy on 04/28/2003 12:00am

    Originally posted by: Raju Selvaraj

    Dear Sir,
    Its really a useful stuff.
    >In this i want to include provision for TIFF,WMF formats.
    How to include provision for that.
    >I want to compare two images bit by bit,how to code for that.
    > if the bit value differs,i have to mark the different bit as another color,and draw in a different file and display the resultant image.
    Plase help me.
    I'll be thank full if u reply for this.
    Thanks,
    Raju Selvaraj

    Reply
  • Flicker problem when opening large images

    Posted by Legacy on 11/23/2002 12:00am

    Originally posted by: netman

    When using new (old) DIBLOOK to open large images(eg. 200MB), you can always see flick on the edge of client area.
    Would some one help me solve this problem? Thanks a lot!

    Reply
  • Fixes for serialization

    Posted by Legacy on 08/07/2002 12:00am

    Originally posted by: Bob Wakefield

    I was very glad to find this DIB class. It saved me no end of grief writing my own. *However*, it does not serialize a DIB embedded in another file properly.

    The first problem is that the CDib::Serialize function must call ar.Flush () before calling ar.GetFile (). This makes sure that the archive has written its buffer to the CFile.

    The second problem is that CDib::Read ( CFile &file ) uses the file size from CFile::GetLength () instead of reading the bitmap file size from the BITMAPFILEHEADER.bfSize field. This means that an embedded BMP expects to read more data than there is in the bitmap. CDib::Read exits with an error.

    Reply
  • find mouse position

    Posted by Legacy on 07/06/2002 12:00am

    Originally posted by: suguna

    I am working on DIBs . I want to find the mouse position . Can anyone please help?

    Reply
  • Problem in getting caret position in RichEditCtrl

    Posted by Legacy on 06/03/2002 12:00am

    Originally posted by: Jamil Anwar

    I am using rich edit control in my application and facing problem in getting the Caret position in my rich edit cntrol. Actually I insert an HTML tag like <B> by clicking a button and want to save the caret position so that after inserting </B> tag i again go to the position in mid of <B> and </B> i.e. <B>|</B>.
    Please some one help me in solving this problem.
    Jamil Anwar from QAU.

    Reply
  • How to create a copy of the image?

    Posted by Legacy on 10/21/2001 12:00am

    Originally posted by: Bahman Tahayori

    Dear jorge,

    Thanks a lot for your nice en_diblook code. I found it very interesting.

    I am an MSc Student of Bioelectrical engineering. I want to show BMP images and do some processes on it.

    My question is here: Suppose that I have processed an image and I want to show it after the process, How can I do this. i want to use your program as my base program.

    Lets simlify the case. Suppose that I want to add a menu Item to Edit, with the name Process.

    So Edit\Process:

    and the process is just creating a copy of the image in a new window. So by clicking the Edit\Process we will see a copy of the main image.

    How can i do such a thing? i really need your help. Please guide me.

    I am waiting for your response,

    With complements,

    Bahman Tahayori

    Reply
  • Bugs?

    Posted by Legacy on 11/27/2000 12:00am

    Originally posted by: Clement


    Thank you very much for your submission.

    I tried saving a 330*475 RLE8 bitmap with the "Save As" function to save an existing bitmap as another file. However, I found that the output bitmap is a truncated one.

    I did the same with the original diblook and it works fine. May I know where has gone wrong?

    Another question is how do I make a window to open to the image size without scrollbars when the image is small enough to be shown on-screen.

    By the way, are you still working on this application? Do you mind posting a copy of the latest version?


    Thank you very much.

    Reply
  • Bitmap Info Memory Allocation

    Posted by Legacy on 08/15/2000 12:00am

    Originally posted by: Jon T.

    I have been looking through your code and I have a question.
    In your CDib::Read function, when you allocate the global pointer m_pBMI, you use this code:

    m_pBMI = (LPBITMAPINFO)GlobalAllocPtr(GHND, bmfHeader.bfOffBits-sizeof(BITMAPFILEHEADER) + 256*sizeof(RGBQUAD));

    I was wondering why you added the 256 * sizeof(RGBQUAD). I know that this is the size of the RGBQUAD portion of the BITMAPINFO structure, but it seems like that is already taken care of. From what I understand, bfOffBits is the number of bytes between the start of the bitmap file to the actual image. Therefore, if you take bfOffBits, subtract the size of the BITMAPFILEHEADER, AND add the size of the RGBQUAD section, you end up with the size of the BITMAPINFOHEADER plus twice the size of the RGBQUAD section.
    Why did you do this?

    Reply
  • How do you fit the window to the image?

    Posted by Legacy on 05/30/2000 12:00am

    Originally posted by: Tom Gettys

    This is a very helpful sample. I have used it successfully to build a toolkit of image processing algorithms.

    When an image is loaded the window is of a fixed size; I would like to know how to resize the window to fit the image (assuming the image is small enough to fit on the screen).

    Reply
  • BitMap

    Posted by Legacy on 11/29/1999 12:00am

    Originally posted by: jolly

    How To add a bit map on a push Button????

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: August 14, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Data protection has long been considered "overhead" by many organizations in the past, many chalking it up to an insurance policy or an extended warranty you may never use. The realities of today make data protection a must-have, as we live in a data driven society. The digital assets we create, share, and collaborate with others on must be managed and protected for many purposes. Check out this upcoming eSeminar and join eVault Chief Technology …

  • Is your sales and operations planning helping or hurting your bottom line? Here are 5 useful tips from the experts at Quintiq to guide you to a better S&OP strategy.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds