Re: Creating bitmap with specific size and resolution



On Mar 13, 5:17 pm, "Amil Hanish" <amilhan...@xxxxxxxxxxx> wrote:
How do I create a Bitmap and Graphics object for a specific size and
resolution.  For example, let's say I want an image that is 5 inches wide
with a resolution of 300dpi?

Also, how would this be different if I wanted to create it for 5 centimeters
instead?

Thanks.  Amil


Hi,

You can use the following APIs to create a bitmap file in memory,
these functions should work fine for a 24-BIT (true color)
display mode:

//* Prepare DCs & bitmaps... *//

GetDC()

CreateCompatibleDC()

GetDeviceCaps() HORZRES

GetDeviceCaps() VERTRES

CreateCompatibleBitmap()

GetObject()

SelectObject()

CreateDIBitmap()

CreateSolidBrush()

SelectObject() new brush

Rectangle()

SelectObject() old brush


//* Save bitmap into file... *//

GlobalAlloc()

GetDIBits()

CreateFile()

WriteFile()

CloseHandle()


//* Cleanup... *//

GlobalFree()

DeleteObject()

DeleteObject() new brush

DeleteDC()

ReleaseDC()

http://msdn2.microsoft.com/en-us/library/ms533241(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/ms533239(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/ms533266(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/ms532287(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/ms533268.aspx

http://msdn2.microsoft.com/en-us/library/ms533272(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/ms532315(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/ms532387(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/ms533879.aspx

http://msdn2.microsoft.com/en-us/library/aa366574(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/ms532334(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/aa363858(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/aa365747(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/ms724211(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/aa366579(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/ms533225.aspx

http://msdn2.microsoft.com/en-us/library/ms533229(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/ms533251(VS.85).aspx

Kellie.

.



Relevant Pages


Loading