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. GDI+

GDI+

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelpwinformsquestion
12 Posts 5 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.
  • _ __erfan__

    hi. i want to write an image processing program and i don't need to preview the image so i decided to use win32 console application to avoid any unwanted delays. i want to use GDI+ classes but there is a runtime error. my program :

    #include "stdafx.h"
    #include ;
    #include ;
    using namespace Gdiplus;
    int main()
    {
    Bitmap *bmp;
    bmp = new Bitmap(L"my image path");
    unsigned int w = bmp->GetWidth(); // the error occurs in this line

        // my process
        //...
    return 0;
    

    }

    the error : Unhandled exception at 0x00411761 in GdiPlusTest.exe: 0xC0000005: Access violation reading location 0x00000004. any help? thanks.

    CPalliniC Offline
    CPalliniC Offline
    CPallini
    wrote on last edited by
    #2

    __erfan__ wrote:

    i want to write an image processing program and i don't need to preview the image so i decided to use win32 console application to avoid any unwanted delays.

    Hey, you're in the un-managed world here. :-D Probably the bitmap object it is incorrectly built because you've not initialized, as required, the GDI+ library (MSDN [^]):

    You must call GdiplusStartup before you create any GDI+ objects, and you must delete all of your GDI+ objects (or have them go out of scope) before you call GdiplusShutdown.

    :)

    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
    [My articles]

    In testa che avete, signor di Ceprano?

    N _ 2 Replies Last reply
    0
    • _ __erfan__

      hi. i want to write an image processing program and i don't need to preview the image so i decided to use win32 console application to avoid any unwanted delays. i want to use GDI+ classes but there is a runtime error. my program :

      #include "stdafx.h"
      #include ;
      #include ;
      using namespace Gdiplus;
      int main()
      {
      Bitmap *bmp;
      bmp = new Bitmap(L"my image path");
      unsigned int w = bmp->GetWidth(); // the error occurs in this line

          // my process
          //...
      return 0;
      

      }

      the error : Unhandled exception at 0x00411761 in GdiPlusTest.exe: 0xC0000005: Access violation reading location 0x00000004. any help? thanks.

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #3

      __erfan__ wrote:

      Unhandled exception at 0x00411761 in GdiPlusTest.exe: 0xC0000005: Access violation reading location

      You have to initialize GDI+ before you make any GDI+ calls. check GdiplusStartup()[^] function

      nave [My Articles] [My Blog]

      1 Reply Last reply
      0
      • _ __erfan__

        hi. i want to write an image processing program and i don't need to preview the image so i decided to use win32 console application to avoid any unwanted delays. i want to use GDI+ classes but there is a runtime error. my program :

        #include "stdafx.h"
        #include ;
        #include ;
        using namespace Gdiplus;
        int main()
        {
        Bitmap *bmp;
        bmp = new Bitmap(L"my image path");
        unsigned int w = bmp->GetWidth(); // the error occurs in this line

            // my process
            //...
        return 0;
        

        }

        the error : Unhandled exception at 0x00411761 in GdiPlusTest.exe: 0xC0000005: Access violation reading location 0x00000004. any help? thanks.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #4

        Hi, Its because you have not called the GdiplusStartup Function[^] Best Wishes, -David Delaune

        1 Reply Last reply
        0
        • CPalliniC CPallini

          __erfan__ wrote:

          i want to write an image processing program and i don't need to preview the image so i decided to use win32 console application to avoid any unwanted delays.

          Hey, you're in the un-managed world here. :-D Probably the bitmap object it is incorrectly built because you've not initialized, as required, the GDI+ library (MSDN [^]):

          You must call GdiplusStartup before you create any GDI+ objects, and you must delete all of your GDI+ objects (or have them go out of scope) before you call GdiplusShutdown.

          :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          N Offline
          N Offline
          Naveen
          wrote on last edited by
          #5

          ops... A photo finish. and you won :)

          nave [My Articles] [My Blog]

          L 1 Reply Last reply
          0
          • N Naveen

            ops... A photo finish. and you won :)

            nave [My Articles] [My Blog]

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #6

            I'm pretty sure he has borrowed some of Rajesh's monkeys. He only slept 4 hours last night. He is training them to play chess. :laugh: Best Wishes, -David Delaune

            N CPalliniC 2 Replies Last reply
            0
            • L Lost User

              I'm pretty sure he has borrowed some of Rajesh's monkeys. He only slept 4 hours last night. He is training them to play chess. :laugh: Best Wishes, -David Delaune

              N Offline
              N Offline
              Naveen
              wrote on last edited by
              #7

              haaa...He took drug. see 'espresso'[^]

              nave [My Articles] [My Blog]

              1 Reply Last reply
              0
              • CPalliniC CPallini

                __erfan__ wrote:

                i want to write an image processing program and i don't need to preview the image so i decided to use win32 console application to avoid any unwanted delays.

                Hey, you're in the un-managed world here. :-D Probably the bitmap object it is incorrectly built because you've not initialized, as required, the GDI+ library (MSDN [^]):

                You must call GdiplusStartup before you create any GDI+ objects, and you must delete all of your GDI+ objects (or have them go out of scope) before you call GdiplusShutdown.

                :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                _ Offline
                _ Offline
                __erfan__
                wrote on last edited by
                #8

                thank you.

                1 Reply Last reply
                0
                • _ __erfan__

                  hi. i want to write an image processing program and i don't need to preview the image so i decided to use win32 console application to avoid any unwanted delays. i want to use GDI+ classes but there is a runtime error. my program :

                  #include "stdafx.h"
                  #include ;
                  #include ;
                  using namespace Gdiplus;
                  int main()
                  {
                  Bitmap *bmp;
                  bmp = new Bitmap(L"my image path");
                  unsigned int w = bmp->GetWidth(); // the error occurs in this line

                      // my process
                      //...
                  return 0;
                  

                  }

                  the error : Unhandled exception at 0x00411761 in GdiPlusTest.exe: 0xC0000005: Access violation reading location 0x00000004. any help? thanks.

                  _ Offline
                  _ Offline
                  __erfan__
                  wrote on last edited by
                  #9

                  thank you all.

                  CPalliniC R 2 Replies Last reply
                  0
                  • L Lost User

                    I'm pretty sure he has borrowed some of Rajesh's monkeys. He only slept 4 hours last night. He is training them to play chess. :laugh: Best Wishes, -David Delaune

                    CPalliniC Offline
                    CPalliniC Offline
                    CPallini
                    wrote on last edited by
                    #10

                    Randor wrote:

                    I'm pretty sure he has borrowed some of Rajesh's monkeys

                    Randor wrote:

                    He is training them to play chess.

                    I actually was persuading one of them (the most appealing female of the group) to have some ... (well I suppose it's not sister kid safe) :-D

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    In testa che avete, signor di Ceprano?

                    1 Reply Last reply
                    0
                    • _ __erfan__

                      thank you all.

                      CPalliniC Offline
                      CPalliniC Offline
                      CPallini
                      wrote on last edited by
                      #11

                      Looks like the missing initialization didn't pass unnoticed... :-D

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                      [My articles]

                      In testa che avete, signor di Ceprano?

                      1 Reply Last reply
                      0
                      • _ __erfan__

                        thank you all.

                        R Offline
                        R Offline
                        Rajesh R Subramanian
                        wrote on last edited by
                        #12

                        Hi, Please mark the correct answers(s) that helped you by clicking "Good Answer". I've done it for you now.

                        “Follow your bliss.” – Joseph Campbell

                        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