GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 01-Sep-2017, 15:47
tony.yutian tony.yutian is offline
New Member
 
Join Date: Sep 2017
Posts: 1
tony.yutian is on a distinguished road

setWorldTransform giving me trouble!


Hello everybody, I am running into a very weird issue.

I need to draw in memory and then read the buffer from the picture and write to a display device. It was working all fine until 1 day I need to use setWorldTransform in a different memory picture, and the world start turning weird.

Below is the test code I have. You can simply copy all to a empty application, and call this function anywhere.
CPP / C++ / C Code:
void TestCImage()
{
	CRect rectWhere(5, 5, 10, 10);
	CImage img1, img2;
	CDC *pDC1, *pDC2;
	CBrush brush;
	XFORM xf1 = { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 };
	XFORM xf2 = { 1.1, 0.0, 0.0, 1.1, 0.0, 0.0 };
	XFORM xf3 = { 1.001, 0.0, 0.0, 1.001, 0.0, 0.0 };

	brush.CreateSolidBrush(0xaaaaaa);

	img1.Create(200, 200, 32);
	pDC1 = CDC::FromHandle(img1.GetDC());
	pDC1->SetGraphicsMode(GM_ADVANCED);
	pDC1->SetWorldTransform(&xf2); //this is the weird part. xf1 and xf3 will be fine. xf2 cause the trouble. but, but, but! how would any settings on img1 and pDC1 affect the result in img2??????? they are totally in different variable ok???? and I did not do anything after I call SetWorldTransform???

	img1.ReleaseDC();

	img2.Create(20, 20, 32);
	pDC2 = CDC::FromHandle(img2.GetDC());
	pDC2->FillRect(rectWhere, &brush);

	COLORREF* color = (COLORREF*)img2.GetPixelAddress(rectWhere.left, rectWhere.top);
	TRACE("\nValue is %X\n", color[0]);      //suppose to be AAAAAA, if use xf2 in the SetWorldTransform, this value will become 0.
	img2.ReleaseDC();
}
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I am having trouble learning C++ trevton C++ Forum 2 18-Dec-2010 19:29
C programming trouble Newworld C Programming Language 8 12-Sep-2004 23:06
Visual C++ 6.0 trouble LuciWiz MS Visual C++ / MFC Forum 3 02-Aug-2004 06:40
Having trouble trying to format C: Nickster64 Computer Software Forum - Windows 2 27-Jul-2004 07:31

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:12.


vBulletin, Copyright © 2000 - 2017, Jelsoft Enterprises Ltd.