Thread: GDI + problem

  1. #1
    Registered User cfrost's Avatar
    Join Date
    Apr 2004
    Posts
    119

    Post GDI + problem

    I m now using .NET
    And I have a little problem in understanding Graphics class...
    Question raised in my mind is that:

    Is it a helper class for drawing or is it like CDC having objects assosiated with it...

    What is effect of writing:

    Graphics grph(dc);

    Are we getting object from dc or just using it...
    If we are using dc then how can i save some thing drawn on CBitmap that is used by that dc ...
    I am well Fimiliar with Image and Bitmap class and I also know how to save images using them
    Last edited by cfrost; 08-24-2004 at 04:45 AM.

  2. #2
    Registered User cfrost's Avatar
    Join Date
    Apr 2004
    Posts
    119
    Looks like know one expert here

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    The Graphics class encapsulates a device context. It is an object like any other reference type in .NET.

    Are we getting object from dc or just using it...
    I have never seen a Graphics object created by a contructor. You can call the static FromHdc and FromHwnd methods to get a new Graphics object though. You then get a System.Drawing.Graphics instance that encapsulates this device context.

    You can manipulate Images by calling Gaphics::FromImage first to get a Graphics object for this Image. After manipulating the Image by using methods of this Graphics object, you can save the image by calling the Save method on your Image.

    Questions concerning .NET might be answered faster if you put them into the C# Board
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  4. #4
    Registered User cfrost's Avatar
    Join Date
    Apr 2004
    Posts
    119

    Bit bliting CBitmap on to Image Object

    How can i BitBlit a CBitmap Object into a Image Object .....
    I want to save CBitmap via Image

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    The MFC CBitmap class has a cast operator to retrieve an HBITMAP.

    The GDI+ Bitmap class, which inherits from the Image class, has a constructor that accepts an HBITMAP.

    Put these two bits of information together and you have a conversion from an MFC CBitmap to a GDI+ Image.

  6. #6
    Registered User cfrost's Avatar
    Join Date
    Apr 2004
    Posts
    119
    it also requires HPLATTE how can i get platte??

  7. #7
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Try using NULL.

  8. #8
    Registered User cfrost's Avatar
    Join Date
    Apr 2004
    Posts
    119
    Thanx anonytmouse but what is logic of passing NULL (sorry for question again)
    Software is like sex it is good when it is free

  9. #9
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    NULL passed to a function call typically signifies an empty argument or tells the function to use the default. In this case, you don't have an HPALETTE so you can try passing NULL. I suspect it will work but you could confirm if it works or not after trying it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM