Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
CImage is a class which is present in the ATL(Active Template Library). The ATL(Active Template Library) is a set of template-based C++ classes.
CImage gives bitmap support. It has the ability to load and save images JPEG (Joint Photographic Experts Group), BMP (Bitmap Image file), PNG (Portable Network Graphics), and GIF (Graphics Interchange Format) formats.
Syntax
Now, let's have a look what is the syntax for using CImage.
class CImage
Public Methods
Name of the method
Description
CImage::AlphaBlend
It displays bitmaps that have transparent or semitransparent pixels.
CImage::Attach
It attaches an HBITMAP to the CImage object. Can be used with either DIB section bitmaps or non-DIB section bitmaps.
CImage::BitBlt
It copies a bitmap from the source device context to this current device context.
CImage::Create
It creates a DIB section bitmap and attaches it to the previously constructed CImage object.
CImage::CreateEx
It is similar to the CImage::Create creates a DIB section bitmap but with additional parameters and attaches the same to the previously constructed CImage object.
CImage::Destroy
It detaches the bitmap from the CImage object and destroys the bitmap.
CImage::Detach
It detaches the bitmap from a CImage object.
CImage::Draw
It copies a bitmap into a destination rectangle from the source rectangle. Compresses the bitmap or draw stretches to fit the dimensions(pixels) of the destination rectangle, if necessary, and transparent colours and handles alpha blending.
CImage::GetBits
It retrieves a pointer to the actual pixel values of the bitmap.
CImage::GetBPP
It retrieves the bits per pixel.
CImage::GetColorTable
It retrieves RGB(red, green, blue) values (RGB) color values from the range of entries in the color table.
CImage::GetDC
It retrieves the device context into which the current bitmap is selected.
CImage::GetExporterFilterString
It finds the available image formats and their descriptions.
CImage::GetHeight
It retrieves the height of the current image in pixels.
CImage::GetImporterFilterString
It finds the available image formats and their descriptions.
CImage::GetMaxColorTableEntries
It retrieves the maximum number of entries in the colour table.
CImage::GetPitch
It retrieves the pitch of the current image, in bytes.
CImage::GetPixel
It retrieves the color of the pixel specified by x and y.
CImage::GetPixelAddress
It retrieves the address of a given pixel.
CImage::GetTransparentColor
It retrieves the position of the transparent colour in the colour table.
CImage::GetWidth
It retrieves the width of the current image in pixels.
CImage::IsDIBSection
It determines if the attached bitmap is a DIB section.
CImage::IsIndexed
It indicates that a bitmap's colours are mapped to an indexed palette.
CImage::IsNull
It indicates if a source bitmap is currently loaded.
CImage::IsTransparencySupported
It indicates whether the application supports transparent bitmaps.
CImage::Load
It loads an image from the specified file.
CImage::LoadFromResource
It loads an image from the specified resource.
CImage::MaskBlt
It combines the colour data for both the destination and source bitmaps using the raster operation specified mask.
CImage::PlgBlt
It performs a bit-block transfer from a rectangle in the source device context into a //gm(parallelogram) in the destination device context.
CImage::ReleaseDC
It releases the device context that was retrieved with the CImage::GetDC.
CImage::ReleaseGDIPlus
Releases resources used by GDI+. Need to be called to free the resources created by the global CImage object.
CImage::Save
It saves an image as the specified type. Save cannot specify image options.
CImage::SetColorTable
It sets red, green, and blue RGB) colour values in a range of entries in the colour table of the DIB section.
CImage::SetPixel
It sets the pixel at the specified coordinates to the specified color.
CImage::SetPixelIndexed
It sets the pixel at the specified coordinates at the specified index of the palette to the color.
CImage::SetPixelRGB
It sets the pixel at the specified coordinates to the specified RGB(red, green, and blue) value.
CImage::SetTransparentColor
It sets the index of the color to be treated as transparent. Only one colour in a palette can be transparent.
CImage::StretchBlt
It copies a bitmap from a source rectangle into the destination rectangle, compressing or stretching the bitmap to fit the dimensions(pixels) of the destination rectangle, if necessary.
CImage::TransparentBlt
It copies a bitmap with transparent colour to the current device context from the source device context.
Requirements
The required header is atlimage.h
CImage::AlphaBlend
It displays bitmaps that have transparent or semitransparent pixels.
BOOL AlphaBlend(
HDC hDestDC,
int xDest,
int yDest,
BYTE bSrcAlpha = 0xff,
BYTE bBlendOp = AC_SRC_OVER) const throw();
BOOL AlphaBlend(
HDC hDestDC,
const POINT& pointDest,
BYTE bSrcAlpha = 0xff,
BYTE bBlendOp = AC_SRC_OVER) const throw();
BOOL AlphaBlend(
HDC hDestDC,
int xDest,
int yDest,
int nDestWidth,
int nDestHeight,
int xSrc,
int ySrc,
int nSrcWidth,
int nSrcHeight,
BYTE bSrcAlpha = 0xff,
BYTE bBlendOp = AC_SRC_OVER);
BOOL AlphaBlend(
HDC hDestDC,
const RECT& rectDest,
const RECT& rectSrc,
BYTE bSrcAlpha = 0xff,
BYTE bBlendOp = AC_SRC_OVER);
You can also try this code with Online C++ Compiler
Alright! Now we hope you understand the UtilityClass-CImage.
Frequently Asked Questions
What is a utility class?
Utility class is a class that has only stratic methods that perform certain operations on the objects passed as parameters. Utility classes generally have no state.
What is ATL?
ATL stands for the Active Template Library. ATL is a set of template-based C++ classes developed by Microsoft, and had the intentions to simplify the programming of Component Object Model objects.
What is MFC?
MFC stands for Microsoft Foundation Class Library. MFC is a C++ object-oriented library for developing desktop applications for Windows. MFC was introduced by Microsoft in 1992 and quickly gained widespread use.
What are the classes shared by MFC and ATL?
The classes that are shared by MFC and ATL are CFileTime, CFileTimeSpan, CFixedStringT, CImage, COleDateTime, COleDateTimeSpan, CPoint, CRect, CSimpleStringT, CSize, CStrBufT, CStrBufT, CStringT, CTime, CTimeSpan, and IAtlStringMgr.
Conclusion
In this article, we discussed the UtilityClass-CImage. We hope this blog on UtilityClass-CImage was helpful. You can also refer to other similar articles.