Click here to Skip to main content
15,894,646 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Resizing animations/images Pin
m_1729-Jul-09 3:12
m_1729-Jul-09 3:12 
AnswerRe: Resizing animations/images [modified] Pin
Adam Roderick J29-Jul-09 3:11
Adam Roderick J29-Jul-09 3:11 
GeneralRe: Resizing animations/images Pin
m_1729-Jul-09 18:50
m_1729-Jul-09 18:50 
QuestionHow do I get the correct font height in Hindi fonts? Pin
Gywox29-Jul-09 2:11
Gywox29-Jul-09 2:11 
AnswerRe: How do I get the correct font height in Hindi fonts? [modified] Pin
Adam Roderick J29-Jul-09 2:27
Adam Roderick J29-Jul-09 2:27 
AnswerRe: How do I get the correct font height in Hindi fonts? Pin
Iain Clarke, Warrior Programmer29-Jul-09 2:54
Iain Clarke, Warrior Programmer29-Jul-09 2:54 
GeneralRe: How do I get the correct font height in Hindi fonts? Pin
Adam Roderick J29-Jul-09 3:03
Adam Roderick J29-Jul-09 3:03 
GeneralRe: How do I get the correct font height in Hindi fonts? Pin
Gywox29-Jul-09 4:42
Gywox29-Jul-09 4:42 
Hi all,
Thanks for the feedback.
I have tried your suggestions but no success.
Here is my code.

Gdiplus::Bitmap *pBitmap = NULL;
Gdiplus::Graphics *pGraphics = NULL;
Gdiplus::Pen penRed(Gdiplus::Color(255, 255, 0, 0));
Gdiplus::Font gdiFont(_T("Tahoma"), 80, 0, Gdiplus::UnitPixel);
CString text = _T("मैं हिन्दी नहीं बोल सकता हूँ।");
LOGFONTW logFontW;
Status status;
CRect rectBondary1(50, 50, 1000, 1000);
CRect rectBondary2(50, 50, 1000, 1000);

pBitmap = new Gdiplus::Bitmap(1024, 1024, PixelFormat32bppARGB);
pBitmap->SetResolution(96.0F, 96.0F);

pGraphics = Graphics::FromImage(pBitmap);

pGraphics->Clear(Gdiplus::Color(255, 0, 0, 0));

status = gdiFont.GetLogFontW(pGraphics, &logFontW);

HFONT hFont = ::CreateFontIndirect((LOGFONTW *)&logFontW);

HDC hDC = pGraphics->GetHDC();

HGDIOBJ hOldObject = SelectObject(hDC, hFont);

int result = DrawText(hDC, text, -1, rectBondary1, DT_CALCRECT);

result = DrawText(hDC, text, -1, rectBondary2, 0);

SelectObject(hDC, hOldObject);

DeleteObject(hFont);

pGraphics->ReleaseHDC(hDC);

pGraphics->DrawRectangle(&penRed, rectBondary1.left, rectBondary1.top, rectBondary1.Width(), rectBondary1.Height());

CLSID pngClsid;
GetEncoderClsid(_T("image/png"), &pngClsid);
pBitmap->Save(_T("test.png"), &pngClsid, NULL);

if (pGraphics)
    delete pGraphics;

if (pBitmap)
    delete pBitmap;


Help method.

int CTextRenderAnalyzeDialog::GetEncoderClsid(const WCHAR *pFormat, CLSID *pClsid)
{
	UINT uiNumber = 0;
	UINT uiSize = 0;

	ImageCodecInfo *pImageCodecInfo = NULL;

	GetImageEncodersSize(&uiNumber, &uiSize);
	if(uiSize == 0)
	{
		return -1;
	}
	pImageCodecInfo = (ImageCodecInfo *)(malloc(uiSize));
	if (pImageCodecInfo == NULL)
	{
		return -1;
	}
	GetImageEncoders(uiNumber, uiSize, pImageCodecInfo);
	for (UINT uiIndex = 0; uiIndex < uiNumber; ++uiIndex)
	{
		if (wcscmp(pImageCodecInfo[uiIndex].MimeType, pFormat) == 0)
		{
			*pClsid = pImageCodecInfo[uiIndex].Clsid;
			free(pImageCodecInfo);
			return uiIndex;
		}
	}
	free(pImageCodecInfo);
	return -1;
}

QuestionHow to GetHandle of Windows from Resource ID in ATL COM Pin
am 200929-Jul-09 1:43
am 200929-Jul-09 1:43 
AnswerRe: How to GetHandle of Windows from Resource ID in ATL COM Pin
Adam Roderick J29-Jul-09 1:55
Adam Roderick J29-Jul-09 1:55 
AnswerRe: How to GetHandle of Windows from Resource ID in ATL COM Pin
Iain Clarke, Warrior Programmer29-Jul-09 2:55
Iain Clarke, Warrior Programmer29-Jul-09 2:55 
QuestionHow to control other non-focus application? Pin
audi0229-Jul-09 1:12
audi0229-Jul-09 1:12 
AnswerRe: How to control other non-focus application? Pin
Adam Roderick J29-Jul-09 1:41
Adam Roderick J29-Jul-09 1:41 
GeneralRe: How to control other non-focus application? Pin
audi0229-Jul-09 9:59
audi0229-Jul-09 9:59 
QuestionRe: How to control other non-focus application? Pin
audi023-Aug-09 22:49
audi023-Aug-09 22:49 
QuestionCreating a Data stream Pin
VCProgrammer29-Jul-09 0:55
VCProgrammer29-Jul-09 0:55 
AnswerRe: Creating a Data stream Pin
Iain Clarke, Warrior Programmer29-Jul-09 2:59
Iain Clarke, Warrior Programmer29-Jul-09 2:59 
QuestionHow to display the OpenCV image in CView (MFC) Pin
Sonhye Aui28-Jul-09 23:56
Sonhye Aui28-Jul-09 23:56 
QuestionHow to set proxy with xmlhttprequest Pin
Ash_VCPP28-Jul-09 23:30
Ash_VCPP28-Jul-09 23:30 
QuestionCHttpFile::SendRequest problem Pin
msn9228-Jul-09 22:29
msn9228-Jul-09 22:29 
AnswerRe: CHttpFile::SendRequest problem Pin
msn9228-Jul-09 22:58
msn9228-Jul-09 22:58 
GeneralRe: CHttpFile::SendRequest problem Pin
Swapnil Shah28-Jul-09 23:11
Swapnil Shah28-Jul-09 23:11 
GeneralRe: CHttpFile::SendRequest problem Pin
msn9229-Jul-09 1:32
msn9229-Jul-09 1:32 
QuestionScrolling into CListCtrl Pin
siko228-Jul-09 22:13
siko228-Jul-09 22:13 
AnswerRe: Scrolling into CListCtrl Pin
«_Superman_»28-Jul-09 22:49
professional«_Superman_»28-Jul-09 22:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.