-
September 22nd, 2005, 05:40 AM
#1
How to create DC with specific resolution?
Hi GURUs,
Do you know how to create DC with specific resolution? Normally, I created DC by calling CDC::CreateCompatibleDC(NULL);. This will create the DC with the screen resolution (96dpi). If you call CDC::GetDeviceCaps(LOGPIXELSX);, you will see that the return value is 96.
So, I am just wondering, how to create a DC with specific resolution such as 200x200 or 120x103, etc...? If this is not possible, how to set the temporary resolution of the DC at runtime?
Thanks for any help in advance...
Cheers
-
September 22nd, 2005, 06:36 PM
#2
Re: How to create DC with specific resolution?
Can anyone help me, please? GURU???
-
September 22nd, 2005, 07:46 PM
#3
Re: How to create DC with specific resolution?
the dpi is dependent on h/w , right ?
-
September 22nd, 2005, 07:49 PM
#4
Re: How to create DC with specific resolution?
Hi Kirants,
I think so.
I think the resolution in DC depends on the hardware. Therefore, I am just wondering if I could create "a temporary DC" with specific resolution.
Any idea?
Thanks...
-
September 22nd, 2005, 08:01 PM
#5
Re: How to create DC with specific resolution?
A resolution only applies to a physical entity , right ? A memory DC doesn't have that. A memory DC is simply a canvas and doesn't have to draw at 96dpi on the screen.
So, I am confused..
Are you sure you are concerned about resolution and not something else ? You aren't talking about the viewport coordinates, are you.. Something like , you want the DC to have a coordinate system of 100 by 100 and all drawing operations would scale accordingly ??
-
September 22nd, 2005, 08:27 PM
#6
Re: How to create DC with specific resolution?
Hi Kirants,
What happen was, I create a CBitmap object and use select this bitmap object to the device context. So, all drawing that being done will be put into this CBitmap object.
Code:
if(m_bmpToDraw.CreateBitmap(width, height, planes, bpp, NULL))
{
m_bmpOld = m_pDC->SelectObject(&m_bmpToDraw);
return TRUE;
}
As you can see, if my m_pDC->GetDeviceCaps(LOGPIXELSX) or m_pDC->GetDeviceCaps(LOGPIXELSY) has resolution of 96x96, the image resolution produced will be 96x96. I need the image resolution to be 200x200 or 200x98 etc...
How to achive this?
Thanks again for your help in advance...
Cheers
Last edited by ryu; September 22nd, 2005 at 08:49 PM.
-
September 22nd, 2005, 08:36 PM
#7
Re: How to create DC with specific resolution?
I don't think you can use this way to create DC with specific resolution.
Andy
---------------------------------------------------------------------------------
XD++ MFC/C++ Flow/Diagram Library (Full Visio 2003 Like,100% Source Code Kit) -- http://www.********.net
-
September 22nd, 2005, 08:49 PM
#8
Re: How to create DC with specific resolution?
Hi Andy,
Is there any workaround on this problem?
Cheers
-
September 22nd, 2005, 08:55 PM
#9
Re: How to create DC with specific resolution?
Originally Posted by ryu
I need the image resolution to be 200x200 or 200x98 etc...
Do you mean, you want the bitmap to be of 200 pixel width and 98 pixel height ?
-
September 22nd, 2005, 09:19 PM
#10
Re: How to create DC with specific resolution?
Hi Kirants,
No... I mean the image resolution need to be 200dpi (in width) and 98dpi (in height). The image size can be any size (such as: 1000pixelx1000pixel, etc...).
You can check the image resolution by:
- open the image in Microsoft Paint (Start + Program + Accessories + Paint)
- Click on Image + Attributes (or press CTRL+E)
- You will see the image attribute resolution.
Thanks again for any helps in advance...
Cheers
Last edited by ryu; September 22nd, 2005 at 10:27 PM.
-
September 22nd, 2005, 11:03 PM
#11
Re: How to create DC with specific resolution?
-
September 28th, 2005, 08:05 PM
#12
Re: How to create DC with specific resolution?
GURU...??? Anyone??? GURU...??? Please help...
-
September 29th, 2005, 06:27 AM
#13
Re: How to create DC with specific resolution?
I understand what you mean, but I am afraid there is no solution.
A DC (Display Context) is associated to a display (or printer) device. The LOGPIXELSX/Y settings are linked to a device and its driver.
Instead of CreateCompatibleDC(), you can do CreateDC(). See the documentation at http://msdn.microsoft.com/library/de...vcons_5g83.asp.
You'll see that you need to give the name of a device and the name of a driver. If you have a device with a driver able to handle 200x96dpi, it's good for you.
You may specify a DEVMODE structure containing settings of devices. See http://msdn.microsoft.com/library/de...tspol_8nle.asp. But you cannot choose settings that are not allowed by your device and its driver.
-
September 29th, 2005, 07:38 AM
#14
Re: How to create DC with specific resolution?
Once you have a DC with a bitmap selected into it, you know the DC is running at 96 (or whetever) DPI. You know this needs to map onto a x * y bitmap.
You can calculate scaling coordinates for the DC in a call to SetWorldTransform, which will scale all commands from one to the other. This means that you could in effect chnage the 96DPI to whatever DPI you need.
Its not something I have done, but I believe you could get it to work.
Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
Please remember to rate useful answers. It lets us know when a question has been answered.
-
September 30th, 2005, 02:48 AM
#15
Re: How to create DC with specific resolution?
Hi RogerAllen,
Thanks for replying
Now, I am getting somewhere. Before I do not know where to look. But is it possible to explain more in details?
If I draw a rectangle:
Code:
m_pDC->Rectangle(10, 10, 100, 100);
How can I make this rectangle being draw using 200dpi instead of 96dpi?
Thanks again for any help, in advance...
Cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|