CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2003
    Location
    Spain
    Posts
    52

    Number of Pixels in a form?

    Hello,
    I want to count how many pixels there are in a window.
    Is there another way apart from using GetPixel to access each pixel ?

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: Number of Pixels in a form?

    GetWindowRect will give you the dimensions of a window ( client area + non-client area) in pixels.

    GetClientRect will give you the dimensions of a client are of a window in pixels.

  3. #3
    Join Date
    Dec 2003
    Location
    Spain
    Posts
    52

    Re: Number of Pixels in a form?

    Thanks, but i had in mind irregular shaped forms. Maybe there's a bmp function to count pixels to avoid using GetPixel. Any further help, please?

  4. #4
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    466

    Smile Re: Number of Pixels in a form?

    GetRegionData is the function that gets information about a region.
    First get region of a form/dialog, then obtain RGNDATA.

    Code:
    HRGN rgn;
    
    if(GetWindowRgn(hDlg, rgn)) {
        RGNDATA rd;
        GetRegionData(rgn, sizeof(RGNDATA), &rd);
    
         DWORD nRects = rd.rdh.nCount; //I think this is what you want
    }
    I hop this helps.

    regards
    » Please 'Rate This Post' if it helped (encourage us to help you more)
    » Build GUI in minute using rad c++
    » Free IDE + GUI code generator - screenshot
    » Free WINAPI sourcecode and tutorials

  5. #5
    Join Date
    Dec 2003
    Location
    Spain
    Posts
    52

    Re: Number of Pixels in a form?

    edit

  6. #6
    Join Date
    Dec 2003
    Location
    Spain
    Posts
    52

    Re: Number of Pixels in a form?

    Thank you very much !!

    I'll try to extract every rectangle from the RGNDATA buffer that contains the RECT structures

    regards

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