Results 1 to 8 of 8

Thread: GetObject

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    I know I posted this on the API site but only 2 people looked at it so I'm putting it here


    OK, I know this is a bit of a dumb question but it's probably quicker for you lot to tell me than to find out for myself by experiment.

    If I use GetObject with a BITMAP type lpObject and a bitmap hObject then will the bmBits part of lpobject be a pointer to the bits of the bitmap.

    I've been using get/set bitmap bits but apparrently it's only for backwards compatibility.

    Am I barking Up the right tree?
    If it wasn't for this sentence I wouldn't have a signature at all.

  2. #2
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554

    Hi Sam

    FROM MSDN:

    GetObject
    The GetObject function retrieves information about a specified graphics object. Depending on the graphics object, the function places a filled-in BITMAP, DIBSECTION, EXTLOGPEN, LOGBRUSH, LOGFONT, or LOGPEN structure, or a count of table entries (for a logical palette), into a specified buffer.

    int GetObject(
    HGDIOBJ hgdiobj, // handle to graphics object
    int cbBuffer, // size of buffer for object information
    LPVOID lpvObject // buffer for object information
    );
    Parameters
    hgdiobj
    [in] Handle to the graphics object of interest. This can be a handle to one of the following: a logical bitmap, a brush, a font, a palette, a pen, or a device independent bitmap created by calling the CreateDIBSection function.
    cbBuffer
    [in] Specifies the number of bytes of information to be written to the buffer.
    lpvObject
    [out] Pointer to a buffer that receives the information about the specified graphics object.
    The following table shows the type of information the buffer receives for each type of graphics object you can specify with hgdiobj. Object type Data written to buffer
    HBITMAP BITMAP
    HBITMAP returned from a call to CreateDIBSection DIBSECTION, if cbBuffer is set to sizeof(DIBSECTION), or BITMAP, if cbBuffer is set to sizeof(BITMAP)
    HPALETTE A WORD count of the number of entries in the logical palette
    HPEN returned from a call to ExtCreatePen EXTLOGPEN
    HPEN LOGPEN
    HBRUSH LOGBRUSH
    HFONT LOGFONT



    If the lpvObject parameter is NULL, the function return value is the number of bytes required to store the information it writes to the buffer for the specified graphics object.

    Return Values
    If the function succeeds, and lpvObject is a valid pointer, the return value is the number of bytes stored into the buffer.

    If the function succeeds, and lpvObject is NULL, the return value is the number of bytes required to hold the information the function would store into the buffer.

    If the function fails, the return value is zero.

    Windows NT/2000: To get extended error information, call GetLastError.

    Remarks
    The buffer pointed to by the lpvObject parameter must be sufficiently large to receive the information about the graphics object.

    If hgdiobj is a handle to a bitmap created by calling CreateDIBSection, and the specified buffer is large enough, the GetObject function returns a DIBSECTION structure. In addition, the bmBits member of the BITMAP structure contained within the DIBSECTION will contain a pointer to the bitmap's bit values.

    If hgdiobj is a handle to a bitmap created by any other means, GetObject returns only the width, height, and color format information of the bitmap. You can obtain the bitmap's bit values by calling the GetDIBits or GetBitmapBits function.

    If hgdiobj is a handle to a logical palette, GetObject retrieves a 2-byte integer that specifies the number of entries in the palette. The function does not retrieve the LOGPALETTE structure defining the palette. To retrieve information about palette entries, an application can call the GetPaletteEntries function.

    If hgdiobj is a handle to a font, the LOGFONT that is returned is the LOGFONT used to create the font. If Windows had to make some interpolation of the font because the precise LOGFONT could not be represented, the interpolation will not be reflected in the LOGFONT. For example, if you ask for a vertical version of a font that doesn't support vertical painting, the LOGFONT indicates the font is vertical, but Windows will paint it horizontally.

    Requirements
    Windows NT/2000: Requires Windows NT 3.1 or later.
    Windows 95/98: Requires Windows 95 or later.
    Header: Declared in Wingdi.h; include Windows.h.
    Library: Use Gdi32.lib.
    Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

    From what i gather you were nearly ther, but kinda the other way round the former is the handle and the latter is the bits and the bit in the middle just specifies the size of the buffer for the bits.

    DocZaf
    {;->

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Right, I'll have a play with that, I was Kinda Hoping for a yes/no answer, oh well as with everything in the API it's a lot more complicated than you'd think, I've used getobject before, but never using it to try get at the Bitmap bits, I'll try just copying a load of memory from one bitmap to the other using copymemory, that'll be fun.

  4. #4
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    What exactly are you doing Sam?
    Just testing? or do you have a task in mind?

    Zaf

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    I'm doing some controls that look different, they work like standard VB controls but they look as if they're the form kinda distorting, basicly I need to do lot's of calculations on what each pixel looks like so I'm doing it by writing to the bitmap bits directly, I got a prototype working using Get/Set BitmapBits but apparently youre not supposed to use it and I'd prefer to write directly to the bit's rather than writing to a byte array and copying the memory across anyway, although VB being what it is I doubt I can avoid doing this, I'm trying to write some Dlls in C++ but Com being what it is I might as well get it working in VB first.

  6. #6
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    Question Sam:
    Are you more comfortable in VB or in C

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    VB all the Way, I'm still trying to write a C++ Dll that I can connect to in VB, I still need a pointer to the memory in C++, that's the bit I'm trying to do.

  8. #8
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554

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