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. Graphics
  4. Can I push a per-pixel off-screen bitmap operation onto the Graphics Accelerator (DirectDraw, etc.)?

Can I push a per-pixel off-screen bitmap operation onto the Graphics Accelerator (DirectDraw, etc.)?

Scheduled Pinned Locked Moved Graphics
graphicsjsonperformancehelptutorial
3 Posts 2 Posters 0 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
    roscler
    wrote on last edited by
    #1

    I have a program running on Windows 2000 or better PC's that needs to do a per-pixel operation on a Windows bitmap. Currently I'm using a tight loop that does little more than a pointer increment followed by a quick add operation on each pixel over the entire bitmap. This is done in real-time so I need it fast. On a 320 x 240 image that ends up being 230,400 addition operations since they are RGB bitmaps (320 x 240 x 3). This is being done in real time on an image stream that is pumping out 25 frames per second. At that resolution it's fast enough, but at 640 x 480 I have to start dropping frames significantly to keep up. I am not displaying the modified bitmap to the screen at any time. Instead I am shipping it off to a remote location over the Internet for display at the destination system. I was wondering if I could push this operation to the Graphics Accelerator using one of Windows Graphics API's like DirectDraw, etc.? Or do PC Graphic accelerators only help with operations that are drawn to the screen (local PC video memory)? I assume that if it's possible I'd need to pump the bitmap to the Graphics Accelerator and then know how to do a global operation on each pixel and then copy it back to local RAM? If it is possible to use the Graphics Accelerator to help with per-pixel operations on a off-screen bitmap, what are the pros and cons? Finally, is there a way to push JPEG decompression and compression operations onto the Graphics Accelerator? If it is possible to do these things I would like to know where a quick easy to dive into sample is. I don't have any need for shading or rotations or any complex graphics operations at all like that. Therefore I would like to avoid wading through a ton of reading just to learn how to do a simple global pixel operation task. Thanks in advance.

    B 1 Reply Last reply
    0
    • R roscler

      I have a program running on Windows 2000 or better PC's that needs to do a per-pixel operation on a Windows bitmap. Currently I'm using a tight loop that does little more than a pointer increment followed by a quick add operation on each pixel over the entire bitmap. This is done in real-time so I need it fast. On a 320 x 240 image that ends up being 230,400 addition operations since they are RGB bitmaps (320 x 240 x 3). This is being done in real time on an image stream that is pumping out 25 frames per second. At that resolution it's fast enough, but at 640 x 480 I have to start dropping frames significantly to keep up. I am not displaying the modified bitmap to the screen at any time. Instead I am shipping it off to a remote location over the Internet for display at the destination system. I was wondering if I could push this operation to the Graphics Accelerator using one of Windows Graphics API's like DirectDraw, etc.? Or do PC Graphic accelerators only help with operations that are drawn to the screen (local PC video memory)? I assume that if it's possible I'd need to pump the bitmap to the Graphics Accelerator and then know how to do a global operation on each pixel and then copy it back to local RAM? If it is possible to use the Graphics Accelerator to help with per-pixel operations on a off-screen bitmap, what are the pros and cons? Finally, is there a way to push JPEG decompression and compression operations onto the Graphics Accelerator? If it is possible to do these things I would like to know where a quick easy to dive into sample is. I don't have any need for shading or rotations or any complex graphics operations at all like that. Therefore I would like to avoid wading through a ton of reading just to learn how to do a simple global pixel operation task. Thanks in advance.

      B Offline
      B Offline
      Baltoro
      wrote on last edited by
      #2

      It is well known that calling GetPixel and SetPixel on a bitmap by addressing each pixel separately is an extremely time consuming graphics operation. I recently ran into this thread, (at the MASM32 forum) that tests a number of typical graphics operations and determines the required clock cycles: Graphics, Memory DIB[^]. Skip the assembly code and just check out the listings of clock cycles for the GDI operation,...I think you'll be amazed. The DirectX SDK comes with a utility that displays the capabilities of your graphics accelerator. Basically, what you want is: GetDeviceCaps[^]. And, if your graphics accelerator supports Pixel Shaders, perhaps that would be faster. But, this is very time-consuming and error-prone. BitBlt is much faster,...but, I think what you want is to have the bitmap already altered before you need to display it. Undoubtedly, that occurred to you. I'm assuming that you cannot access the bitmap before your application loads, or starts processing.

      R 1 Reply Last reply
      0
      • B Baltoro

        It is well known that calling GetPixel and SetPixel on a bitmap by addressing each pixel separately is an extremely time consuming graphics operation. I recently ran into this thread, (at the MASM32 forum) that tests a number of typical graphics operations and determines the required clock cycles: Graphics, Memory DIB[^]. Skip the assembly code and just check out the listings of clock cycles for the GDI operation,...I think you'll be amazed. The DirectX SDK comes with a utility that displays the capabilities of your graphics accelerator. Basically, what you want is: GetDeviceCaps[^]. And, if your graphics accelerator supports Pixel Shaders, perhaps that would be faster. But, this is very time-consuming and error-prone. BitBlt is much faster,...but, I think what you want is to have the bitmap already altered before you need to display it. Undoubtedly, that occurred to you. I'm assuming that you cannot access the bitmap before your application loads, or starts processing.

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

        Hello Baltoro, I am not using GetPixel/SetPixel. Instead I am using the Bitmap's scanline property to get a pointer to that memory area and simply walking a pointer over that area in a tight loop. I do have access to the bitmap, in fact I call Delphi's JPEG code to decompress, with some optimizations I added to avoid needless memory reallocations between JPEG frames. I have since learned that there is an extension called DXVA (DirectX Video Acceleration), but that it is really tough to work with. However, I was also told that there probably already are JPEG compressors on my system that make use of DXVA. It might end up being an issue of learning how (if possible) to use DirectX to utilize those hardware accelerated compressors, but I have no idea to go about doing that currently. Thanks, Robert

        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