CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: raw display

  1. #1
    Join Date
    May 2011
    Posts
    23

    raw display

    Used some online code example to put a little project to display raw image. The display does not seem to work.
    For some purposes, I like this to work with a dialog based MFC project.XDVView is derived from CScrollView.
    see OnInitDialog() and OnDraw(CDC* pDC).8bit 768x756
    Attached Files Attached Files

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: raw display

    Quote Originally Posted by lch2 View Post
    For some purposes, I like this to work with a dialog based MFC project.XDVView is derived from CScrollView.
    Could you define these"some purposes" to work with a dialog based rather than a SDI MFC project?
    BTW, your code in XDVView::OnDraw has a resource leak (you call ::GetDC but do not call the ReleaseDC)
    Last edited by VictorN; November 28th, 2012 at 03:54 PM.
    Victor Nijegorodov

  3. #3
    Join Date
    May 2011
    Posts
    23

    Re: raw display

    Got a dialog based MFC that is 100% done. Would be nicer to draw a few raw images continuously using a pop up dialog. Worked with SDI long time ago and do not see major point to port everything to SDI. This is not a major show just a few continuous captures and displays. image is 8bit grayscale. There are many similar reasons in the forum.

  4. #4
    Join Date
    May 2011
    Posts
    23

    Re: raw display

    There was a bug in filling the buffer. Now, my problem is, I can not scroll to view entire image. it re-draws the top half only. It needs improvements. attached.
    Attached Files Attached Files

  5. #5
    Join Date
    May 2011
    Posts
    23

    Re: raw display

    any one, any suggestion, help?.

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: raw display

    If it is in a CScrollView derived class - try SetScrollSizes
    Victor Nijegorodov

  7. #7
    Join Date
    May 2011
    Posts
    23

    Re: raw display

    Used the setscrollsizes already. I just can not get the scroll bar sizes right. Probably the OnDraw and SetScrollSizes needs changes.

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: raw display

    Your OnDraw implementation seems to be strange (not to say incorrect!)
    Code:
    void XDVView::OnDraw(CDC* dc)
    {
    	CDocument* pDoc = GetDocument();
    
    	int ht;
    	int wh;
    	ht = Pbmp->bmiHeader.biHeight;
    	wh = Pbmp->bmiHeader.biWidth;
    
    	HDC hdc=::GetDC(m_hWnd);
    
    	SetDIBitsToDevice(hdc,0,0,(DWORD)wh,(DWORD)ht,0,0,0,
    	(WORD)ht,buf,Pbmp,DIB_RGB_COLORS);
    
    }
    Why do you SetDIBitsToDevice to ::GetDC() rather than to CDC* dc) passed in by the framework?
    Besides, you leak the resources since you do not call the ReleaseDC
    Victor Nijegorodov

  9. #9
    Join Date
    May 2011
    Posts
    23

    Re: raw display

    already added: SetDIBitsToDevice(dc->GetSafeHdc(),.. and Release(dc); Won't have any performance drawback?. OnDraw is called continuously.

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: raw display

    You only need to ReleaseDC if you called GetDC. But in your pseudo-code I see no need in GetDC at all!

    OnDraw is NOT called continuously. Is is called only some repaint is needed (usually in response to InvalidateRect.
    Last edited by VictorN; November 29th, 2012 at 03:54 AM.
    Victor Nijegorodov

  11. #11
    Join Date
    May 2011
    Posts
    23

    Re: raw display

    since i use SetDIBitsToDevice(dc->GetSafeHdc(),.. , then I do not need to call the ReleaseDC, right?. If the buffer passed to the SetDIBitsToDevice is refreshed, I have to call the Invalidate to (refresh the) display the current data in the buffer, right?. I wrote a bit of code to test this. I like to read some inputs as well.

  12. #12
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: raw display

    Quote Originally Posted by lch2 View Post
    since i use SetDIBitsToDevice(dc->GetSafeHdc(),.. , then I do not need to call the ReleaseDC, right?
    Yep!

    Quote Originally Posted by lch2 View Post
    If the buffer passed to the SetDIBitsToDevice is refreshed, I have to call the Invalidate to (refresh the) display the current data in the buffer, right?
    Yep!
    Victor Nijegorodov

  13. #13
    Join Date
    May 2011
    Posts
    23

    Re: raw display

    for some reason, had to call the RedrawWindow to update the window properly. Invalidate() would not update it after each buffer updates.

  14. #14
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: raw display

    Yes. It can happen when some other messages (system considers them more "important" than WM_PAINT) are in the message queue.
    Victor Nijegorodov

  15. #15
    Join Date
    May 2011
    Posts
    23

    Re: raw display

    How can I enlarge the filed of view to show more lines without scrolling or with less scrolling?.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured