CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2009
    Posts
    8

    GDI+ (Graphics class) and multi-core

    Hi everyone,

    I posted this in the "Graphics Programming" forum...

    I wrote a C# application (VS2005) that takes a bunch of images and resize them. Now that I have a quad core, I rewrote it to use threads. Each thread load an image and resize it. After many attempts, I can't get the CPU to work over 25%-29% and that means that only 1 core is used. It seems the bottleneck is the DrawImage() method. It looks like this method only handle 1 thread at a time. Is it possible that DrawImage() uses a lock?

    Thx in advance for any hints!

  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: GDI+ (Graphics class) and multi-core

    I would think the DrawImage would actually use the Graphics Processor. Not the CPU.

  3. #3
    Join Date
    Oct 2009
    Posts
    8

    Re: GDI+ (Graphics class) and multi-core

    Interesting point because if it's true then it could explain why DrawImage() runs 1 job at a time. I read this blog (link below) and it looks like GDI+ is based on a software engine.

    http://blogs.technet.com/thomasolsen...ect2d-api.aspx

    Ok, I finally found this info. GDI+ is using a global lock so threading GDI operations is useless (even if each thread has its own Graphics instance):
    http://social.msdn.microsoft.com/for...-03698f73651a/
    Last edited by DrBob; October 30th, 2009 at 01:08 PM.

  4. #4
    Join Date
    Jun 2008
    Posts
    2,477

    Re: GDI+ (Graphics class) and multi-core

    If you need high performance graphics I would suggest using DirectX. If that is overkill and you only need to resize some images, why not do it yourself? Resizing an image is not very difficult (especially if you are only down-sampling) and you can find many algorithms available on the web.

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