MGL_loadJPEGIntoDC
Loads a JPEG file directly into an existing device context.
Declaration
ibool MGLAPI MGL_loadJPEGIntoDC(
MGLDC *dc,
const char *JPEGName,
int dstLeft,
int dstTop,
int num8BitColors)
Prototype In
mgraph.h
Parameters
dc |
Device context to load bitmap into |
JPEGName |
Name of JPEG file to load |
dstLeft |
Left coordinate to load JPEG at |
dstTop |
Top coordinate to load JPEG at |
num8BitColors |
Number of colors for 8-bit image, 0 for RGB images, -1 for grayscale |
Return Value
True if the JPEG file was loaded, false on error.
Description
Locates the specified JPEG file and loads it into the specified device context at the specified destination coordinates. If the JPEG is of a different pixel depth than the device context that it is being loaded into, the JPEG will be converted as it is loaded to the pixel format of the device context it is being loaded into.
If the num8BitColors parameter is set to a value other than 0, it causes the JPEG decoder to quantize down to an 8 bits per pixel bitmap with an optimized floyd-steinberg dither (better than the MGL's simple halftone dithering) using the palette of the destination device context as the source for the dither. The number of significant colors used from the destination device contexts palette for the dither is set by the num8BitColors parameter. If however the destination device context is not 8-bits per pixel, the image is simply decoded as a 24-bit bitmap.
Note that if you set num8BitColors to -1, the JPEG decoder will decode the image as a grayscale bitmap which is faster than decoding the full color image (useful for preview operations etc). Note that images that are decoded as grayscale are 8-bits per pixel with a grayscale color map and should display as true grayscale images in all color depths. If the destination device context is 8-bits per pixel, the color palette will be changed to a grayscale color palette.
When MGL is searching for bitmap files it will first attempt to find the files just by using the filename itself. Hence if you wish to look for a specific bitmap file, you should pass the full pathname to the file that you are interested in. If the filename is a simple relative filename (i.e. “MYFILE.JPEG”), MGL will then search in the BITMAPS directory relative to the path specified in mglpath variable that was passed to MGL_init. As a final resort MGL will also look for the files in the BITMAPS directory relative to the MGL_ROOT environment variable.
If the bitmap file was not found, or an error occurred while reading the bitmap file, this function will return false. You can check the MGL_result error code to determine the cause.
See Also
MGL_availableJPEG, MGL_getJPEGSize,MGL_loadJPEG, MGL_saveJPEGFromDC
Copyright © 2002 SciTech Software, Inc. Visit our web site at http://www.scitechsoft.com