Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. urgent..How to use GetDeviceCaps() n GetPixel() problem

urgent..How to use GetDeviceCaps() n GetPixel() problem

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
6 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    raner
    wrote on last edited by
    #1

    my pgm was using GetPixel() function, but i realize not all device support the function and that we can use GetDeviceCap() to check its RC_BITBLT capability. so though i'm not exactly sure how to use the function, i tried the following.. int test = dc->GetDeviceCaps(RASTERCAPS); (1)It returns me a negative value(-4349)...what does this mean? What shld the function return me if my device has RC_BITBLT capability anyway? (2)If my device doesnt have the capability, what can i do to have the capability? And what determines whether a device has the capability? thks

    S 1 Reply Last reply
    0
    • R raner

      my pgm was using GetPixel() function, but i realize not all device support the function and that we can use GetDeviceCap() to check its RC_BITBLT capability. so though i'm not exactly sure how to use the function, i tried the following.. int test = dc->GetDeviceCaps(RASTERCAPS); (1)It returns me a negative value(-4349)...what does this mean? What shld the function return me if my device has RC_BITBLT capability anyway? (2)If my device doesnt have the capability, what can i do to have the capability? And what determines whether a device has the capability? thks

      S Offline
      S Offline
      Scott H Settlemier
      wrote on last edited by
      #2

      I think it is merely:

      bool bPelSupport=dc->GetDeviceCaps(RASTERCAPS)!=RC_NONE;

      If your display doesn't support raster operations, then I guess there are no pixels? ;-) Render to an offscreen bitmap and test that or directly test against the model from which the display is drawn. (if it is yours)

      R 1 Reply Last reply
      0
      • S Scott H Settlemier

        I think it is merely:

        bool bPelSupport=dc->GetDeviceCaps(RASTERCAPS)!=RC_NONE;

        If your display doesn't support raster operations, then I guess there are no pixels? ;-) Render to an offscreen bitmap and test that or directly test against the model from which the display is drawn. (if it is yours)

        R Offline
        R Offline
        raner
        wrote on last edited by
        #3

        bool bPelSupport=dc->GetDeviceCaps(RASTERCAPS)!=RC_NONE; gives me compilation error...should there be a bracket somewhere? anyway my dc is defined as below,in my CView class...so shouldnt it have pixels?.. CDC *dc=this->GetDC(); Anyway how do i render to an offscreen bitmap? thks

        7 1 Reply Last reply
        0
        • R raner

          bool bPelSupport=dc->GetDeviceCaps(RASTERCAPS)!=RC_NONE; gives me compilation error...should there be a bracket somewhere? anyway my dc is defined as below,in my CView class...so shouldnt it have pixels?.. CDC *dc=this->GetDC(); Anyway how do i render to an offscreen bitmap? thks

          7 Offline
          7 Offline
          73Zeppelin
          wrote on last edited by
          #4

          You render to an offscreen bitmap by creating a memory device context for the bmp, or MemDC. You can then blt (BitBlt) to the memDC before blitting to the screen (or other DC). Something like: CDC MemDC; // Get the current DC and create a compatible memDC MemDC.CreateCompatibleDC(pDC); // Can now Blt to the MemDC... // Do stuff - draw, render, etc... // Don't forget to clean up.. MemDC.SelectObject();

          R S 2 Replies Last reply
          0
          • 7 73Zeppelin

            You render to an offscreen bitmap by creating a memory device context for the bmp, or MemDC. You can then blt (BitBlt) to the memDC before blitting to the screen (or other DC). Something like: CDC MemDC; // Get the current DC and create a compatible memDC MemDC.CreateCompatibleDC(pDC); // Can now Blt to the MemDC... // Do stuff - draw, render, etc... // Don't forget to clean up.. MemDC.SelectObject();

            R Offline
            R Offline
            raner
            wrote on last edited by
            #5

            Guess it'll have to read up on that. But do you know how do i test after i've BitBlt it to offscreen bitmap? thks

            1 Reply Last reply
            0
            • 7 73Zeppelin

              You render to an offscreen bitmap by creating a memory device context for the bmp, or MemDC. You can then blt (BitBlt) to the memDC before blitting to the screen (or other DC). Something like: CDC MemDC; // Get the current DC and create a compatible memDC MemDC.CreateCompatibleDC(pDC); // Can now Blt to the MemDC... // Do stuff - draw, render, etc... // Don't forget to clean up.. MemDC.SelectObject();

              S Offline
              S Offline
              Scott H Settlemier
              wrote on last edited by
              #6

              But if the display device doesn't support blit operations (RASTERCAPS was RC_NONE) then he won't be able to draw to the offscreen image and blit as the last step. He will have to draw to both DCs instead, using the offscreen image merely for examination.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups