|
From: Gregor P. <Gre...@dl...> - 2001-06-20 16:52:28
|
Hi there,
I like to display some Images, the examples in my books are using the
function
DibLoadImage( szFileName )
from the header file
dibfile.h
like
# include "dibfile.h"
BITMAPFILEHEADER* pbmfh;
pbmfh = DibLoadImage( "myPic.bmp" );
...
The Borland Win32 Programmer Reference doesn't know such a function and
Dev-C++ nothing about such a headerfile.
Does someone know what to do?
|
|
From: <jos...@ya...> - 2001-06-21 06:49:58
|
Hi,
I think you're using a user defined function. That function is not in
the Windows API reference. Instead you can use LoadImage(). See below.
--- Gregor Peter <Gre...@dl...> escribió: > Hi there,
>
> I like to display some Images, the examples in my books are using the
> function
> DibLoadImage( szFileName )
> from the header file
> dibfile.h
>
> like
> # include "dibfile.h"
> BITMAPFILEHEADER* pbmfh;
>
> pbmfh = DibLoadImage( "myPic.bmp" );
> ...
>
> The Borland Win32 Programmer Reference doesn't know such a function
> and
> Dev-C++ nothing about such a headerfile.
>
> Does someone know what to do?
The LoadImage function loads an icon, cursor, or bitmap.
HANDLE LoadImage(
HINSTANCE hinst, // handle of the instance that contains the image
LPCTSTR lpszName, // name or identifier of image
UINT uType, // type of image
int cxDesired, // desired width
int cyDesired, // desired height
UINT fuLoad // load flags
);
Parameters
hinst
Identifies an instance of the module that contains the image to be
loaded. To load an OEM image, set this parameter to zero.
lpszName
Identifies the image to load.
If the hinst parameter is non-NULL and the fuLoad parameter does not
include LR_LOADFROMFILE, lpszName is a pointer to a null-terminated
string that contains the name of the image resource in the hinst
module.
If hinst is NULL and LR_LOADFROMFILE is not specified, the low-order
word of this parameter must be the identifier of the OEM image to load.
The OEM image identifiers are defined in WINUSER.H and have the
following prefixes:
Prefix Meaning
OBM_ OEM bitmaps
OIC_ OEM icons
OCR_ OEM cursors
Windows 95: If the fuLoad parameter includes the LR_LOADFROMFILE value,
lpszName is the name of the file that contains the image.
Windows NT: LR_LOADFROMFILE is not supported.
uType
Specifies the type of image to be loaded. This parameter can be one of
the following values:
Value Meaning
IMAGE_BITMAP Loads a bitmap.
IMAGE_CURSOR Loads a cursor.
IMAGE_ICON Loads an icon.
cxDesired
Specifies the width, in pixels, of the icon or cursor. If this
parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the
function uses the SM_CXICON or SM_CXCURSOR system metric value to set
the width. If this parameter is zero and LR_DEFAULTSIZE is not used,
the function uses the actual resource width.
cyDesired
Specifies the height, in pixels, of the icon or cursor. If this
parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the
function uses the SM_CYICON or SM_CYCURSOR system metric value to set
the height. If this parameter is zero and LR_DEFAULTSIZE is not used,
the function uses the actual resource height.
fuLoad
Specifies a combination of the following values:
Value Meaning
LR_DEFAULTCOLOR The default flag; it does nothing. All it means is "not
LR_MONOCHROME".
LR_CREATEDIBSECTION When the uType parameter specifies IMAGE_BITMAP,
causes the function to return a DIB section bitmap rather than a
compatible bitmap. This flag is useful for loading a bitmap without
mapping it to the colors of the display device.
LR_DEFAULTSIZE Uses the width or height specified by the system metric
values for cursors or icons, if the cxDesired or cyDesired values are
set to zero. If this flag is not specified and cxDesired and cyDesired
are set to zero, the function uses the actual resource size. If the
resource contains multiple images, the function uses the size of the
first image.
LR_LOADFROMFILE Loads the image from the file specified by the lpszName
parameter. If this flag is not specified, lpszName is the name of the
resource.
LR_LOADMAP3DCOLORS Searches the color table for the image and replaces
the following shades of gray with the corresponding 3D color:
Color Replaced with
Dk Gray, RGB(128,128,128) COLOR_3DSHADOW
Gray, RGB(192,192,192) COLOR_3DFACE
Lt Gray, RGB(223,223,223) COLOR_3DLIGHT
LR_LOADTRANSPARENT Retrieves the color value of the first pixel in the
image and replaces the corresponding entry in the color table with the
default window color (COLOR_WINDOW). All pixels in the image that use
that entry become the default window color. This value applies only to
images that have corresponding color tables. If fuLoad includes both
the LR_LOADTRANSPARENT and LR_LOADMAP3DCOLORS values, LRLOADTRANSPARENT
takes precedence. However, the color table entry is replaced with
COLOR_3DFACE rather than COLOR_WINDOW.
LR_MONOCHROME Loads the image in black and white.
LR_SHARED Shares the image handle if the image is loaded multiple
times. If LR_SHARED is not set, a second call to LoadImage for the same
resource will load the image again and return a different handle.Do not
use LR_SHARED for images that have non-standard sizes, that may change
after loading, or that are loaded from a file.
Return Values
If the function succeeds, the return value is the handle of the newly
loaded image.
If the function fails, the return value is NULL.
_______________________________________________________________
Do You Yahoo!?
Yahoo! Messenger: Comunicación instantánea gratis con tu gente -
http://messenger.yahoo.es
|
|
From: Gregor P. <Gre...@dl...> - 2001-06-23 20:41:24
|
Hmmm, the LoadImage( ... ) is a part of the Programmers Reference but returns (just) a HANDLE . What I need is a pointer to a BITMAPFILEHEADER to get some informations SetDIBBitsToDevice( ... ) needs to be able to display the loaded Image. I can't find any informations about HANDLEs in the Windows API reference. Is it possible to feed the BITMAPFILEHEADER structure via this HANDLE? Gregor -------- schnipp ---------- Jose Manuel Padron Carrillo wrote: > Hi, > > I think you're using a user defined function. That function is not in > the Windows API reference. Instead you can use LoadImage(). See below. > > --- Gregor Peter <Gre...@dl...> escribió: > Hi there, > > > > I like to display some Images, the examples in my books are using the > > function > > DibLoadImage( szFileName ) > > from the header file > > dibfile.h > > > > like > > # include "dibfile.h" > > BITMAPFILEHEADER* pbmfh; > > > > pbmfh = DibLoadImage( "myPic.bmp" ); > > ... > > > > The Borland Win32 Programmer Reference doesn't know such a function > > and > > Dev-C++ nothing about such a headerfile. > > > > Does someone know what to do? > > The LoadImage function loads an icon, cursor, or bitmap. > > HANDLE LoadImage( > > HINSTANCE hinst, // handle of the instance that contains the image > LPCTSTR lpszName, // name or identifier of image > UINT uType, // type of image > int cxDesired, // desired width > int cyDesired, // desired height > UINT fuLoad // load flags > ); > |
|
From: Elias P. <eli...@ao...> - 2001-06-23 21:07:31
|
> Hmmm, the LoadImage( ... ) is a part of the Programmers Reference but > returns (just) a HANDLE . > What I need is a pointer to a BITMAPFILEHEADER to get some informations > SetDIBBitsToDevice( ... ) needs to be able to display the loaded Image. > I can't find any informations about HANDLEs in the Windows API reference. > Is it possible to feed the BITMAPFILEHEADER structure via this HANDLE? > Gregor Have a look at the GetDIBits() function, it seem to convert from the HANDLE into what you want. Elias Pschernig |
|
From: Gregor P. <Gre...@dl...> - 2001-06-24 18:35:22
|
I fear that won't help cause I don't want to _set_ the parameter I wanna _get_ these informations of the DIB. How to load a Image from disk, let's say "picture.bmp" (which is -just for example- about 50k), findout its dimensions and display it on the screen? Gregor ----- schnipp ----- Elias Pschernig wrote: > > Hmmm, the LoadImage( ... ) is a part of the Programmers Reference but > > returns (just) a HANDLE . > > What I need is a pointer to a BITMAPFILEHEADER to get some informations > > SetDIBBitsToDevice( ... ) needs to be able to display the loaded Image. > > I can't find any informations about HANDLEs in the Windows API reference. > > Is it possible to feed the BITMAPFILEHEADER structure via this HANDLE? > > Gregor > > Have a look at the GetDIBits() function, it seem to convert from the HANDLE > into what you want. > > Elias Pschernig |
|
From: Elias P. <eli...@ao...> - 2001-06-24 19:54:39
|
> I fear that won't help cause I don't want to _set_ the parameter I wanna _get_ > these informations of the DIB. > > How to load a Image from disk, let's say "picture.bmp" (which is -just for > example- about 50k), > findout its dimensions and display it on the screen? I can't look into the documentation right now, but you had a function to display a DIB bitmap. But LoadImage just returns a HANDLE. So you could use the *GET*DIBits function to get the info you need for the display function, from the HANDLE, which you get from the bitmap file on disk. (i will look at the documentation for the 3 functions later..) Elias Pschernig |
|
From: Elias P. <eli...@ao...> - 2001-06-25 19:06:10
|
> I fear that won't help cause I don't want to _set_ the parameter I wanna _get_
> these informations of the DIB.
Yes, I looked at the documentation now, and that function already needs some
info. You could always use GetObject() to get the bitmap dimensions.
> How to load a Image from disk, let's say "picture.bmp" (which is -just for
> example- about 50k),
> findout its dimensions and display it on the screen?
Ok, if that is all you want to do, there's no need for DIBitmaps at all..
I paste some example code which loads and displays a bitmap directly on the
desktop.
Elias Pschernig
--
#include <windows.h>
int WINAPI WinMain(HINSTANCE hinst,HINSTANCE prev,LPSTR arg,int show) {
HANDLE bitmapHandle;
HDC sourceDC, destinationDC;
BITMAP bitmap;
// load bitmap from disk
bitmapHandle = LoadImage(NULL, "test.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
// normally, you will use: destinationDC = GetDC(hWnd); hWnd being the window to
// draw to, never use the desktop for that, for obvious reasons
destinationDC = GetWindowDC(GetDesktopWindow());
// Get data from the handle
GetObject(bitmapHandle, sizeof(bitmap), &bitmap);
// Create compatible device context and tell it to use the bitmap
sourceDC = CreateCompatibleDC(destinationDC);
SelectObject(sourceDC, bitmapHandle);
// draw the bitmap
BitBlt(destinationDC, 0, 0, bitmap.bmWidth, bitmap.bmHeight, sourceDC, 0, 0, SRCCOPY);
// In C, always release stuff you have allocated..
DeleteDC(sourceDC);
ReleaseDC(GetDesktopWindow(), destinationDC);
return 0;
}
|
|
From: <jos...@ya...> - 2001-06-25 07:11:32
|
Actually yes but indirectly. You call LoadImage to get the handle of
the bmp, then call GetObject to get the data you're asking for. See
below for a description of the GetObject function.
--- Gregor Peter <Gre...@dl...> escribió: > Hmmm, the
LoadImage( ... ) is a part of the Programmers Reference
> but returns
> (just) a HANDLE .
>
> What I need is a pointer to a BITMAPFILEHEADER to get some
> informations
> SetDIBBitsToDevice( ... ) needs to be able to display the loaded
> Image.
>
> I can't find any informations about HANDLEs in the Windows API
> reference.
> Is it possible to feed the BITMAPFILEHEADER structure via this
> HANDLE?
>
> Gregor
The GetObject function obtains 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 of interest
int cbBuffer, // size of buffer for object information
LPVOID lpvObject // pointer to buffer for object information
);
Parameters
hgdiobj
A 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
Specifies the number of bytes of information to be written to the
buffer.
lpvObject
Points to a buffer that is to receive 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:
hgdiobj Type Data Written to *lpvObject
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. 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 identifies 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 identifies 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 identifies a logical palette, GetObject retrieves a two-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.
_______________________________________________________________
Do You Yahoo!?
Yahoo! Messenger: Comunicación instantánea gratis con tu gente -
http://messenger.yahoo.es
|