Showing posts with label bitmap. Show all posts
Showing posts with label bitmap. Show all posts

Tuesday, January 21, 2014

XAML close minimize restore and maximize Geometry




·         <Geometry x:Key="closeGeometry">

        F1 M 151,217L 152,217L 154.5,219.5L 157,217L 158,217L 158,218L 155.5,220.5L 158,223L 158,224L 157,224L 154.5,221.5L 152,224L 151,224L 151,223L 153.5,220.5L 151,218L 151,217 Z

    </Geometry>

 

·         <Geometry x:Key="minimizeGeometry">

        M0,0 L8,0 8,1 8,2 0,2 0,1 z

    </Geometry>

 

·         <Geometry x:Key="maximizeGeometry">

        F1 M 34,17L 43,17L 43,23L 34,23L 34,17 Z M 35,19L 35,22L 42,22L 42,19L 35,19 Z

    </Geometry>

 

·         <Geometry x:Key="restoreGeometry">

        M1,4.9996096 L1,7.000219 7,6.999219 7,5.001 2,5.001 2,4.9996096 z M3,2.0014141 L3,3.0000001 8,3.0000001 8,4.0000001 8,4.0008045 9,4.0008045 9,2.0014141 z M2,0 L10,0 10,0.0010234118 10,1.0000001 10,5.001 8,5.001 8,7.9990235 0,8.0000239 0,4.0000001 0,3.0009998 0,3.0000001 2,3.0000001 2,1.0000001 2,0.0010234118 z

    </Geometry>

Thursday, May 7, 2009

Embeding String as overlay on a bitmap

want to write your own string as an overlay of a given bitmap?
Use this code



CFont* pFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));
CFont* pOldFont = dc.SelectObject(pFont);
dc.SetTextColor(RGB(255,255,255));
dc.SetBkMode(TRANSPARENT);
dc.TextOut(500,397,"String");
dc.SelectObject(pOldFont);

Tuesday, May 5, 2009

save rectangle to JPEG

When you need to save a rectangle in your program to a file
the im.Save( "c:\\image.jpg", ImageFormatJPEG); line determines the file format



#include //For Image
using namespace Gdiplus; //For Image

void BitmapUtils::SaveBitmapToFile(HDC hdc,CRect rect)
{
HDC hMemDC = CreateCompatibleDC(hdc);
HBITMAP hBitmap = CreateCompatibleBitmap(hdc,rect.right, rect.Height() + rect.bottom);
if (hBitmap)
{
HBITMAP hOld = (HBITMAP) SelectObject(hMemDC, hBitmap);
BitBlt(hMemDC, 0, 0, rect.right, rect.Height() + rect.bottom, hdc, 0, 0, SRCCOPY);
SelectObject(hMemDC, hOld);
DeleteDC(hMemDC);
::ReleaseDC(NULL, hdc);
}
CImage im;
im.Attach(hBitmap);
im.Save( "c:\\image.jpg", ImageFormatJPEG);
}

Monday, May 4, 2009

Writing a bitmap to a BMP file

Great function to save a bitmap structure to a file

// WriteDIB - Writes a DIB to file
// Returns - TRUE on success
// szFile - Name of file to write to
// hDIB - Handle of the DIB
BOOL WriteDIB( LPTSTR szFile, HANDLE hDIB)
{
BITMAPFILEHEADER hdr;
LPBITMAPINFOHEADER lpbi;

if (!hDIB)
return FALSE;

CFile file;
if( !file.Open( szFile, CFile::modeWrite|CFile::modeCreate) )
return FALSE;

lpbi = (LPBITMAPINFOHEADER)hDIB;

int nColors = 1 << lpbi->biBitCount;

// Fill in the fields of the file header
hdr.bfType = ((WORD) ('M' << 8) | 'B'); // is always "BM"
hdr.bfSize = GlobalSize (hDIB) + sizeof( hdr );
hdr.bfReserved1 = 0;
hdr.bfReserved2 = 0;
hdr.bfOffBits = (DWORD) (sizeof( hdr ) + lpbi->biSize +
nColors * sizeof(RGBQUAD));

// Write the file header
file.Write( &hdr, sizeof(hdr) );

// Write the DIB header and the bits
file.Write( lpbi, GlobalSize(hDIB) );

return TRUE;
}

 
Home | About | Link | Link
Simple Proff Blogger Template Created By Herro | Inspiring By Busy Bee Woo Themes