Re: Vewports and Maping Modes
From: vipin (vipin_at_nospam.com)
Date: 09/03/04
- Next message: vipin: "Re: Charmap inconsistent behaviour"
- Previous message: pango: "how to use "new" to create a Bitmap or image in GDI+"
- In reply to: Corey Cooper: "Re: Vewports and Maping Modes"
- Next in thread: Corey Cooper: "Re: Vewports and Mapping Modes"
- Reply: Corey Cooper: "Re: Vewports and Mapping Modes"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 3 Sep 2004 13:40:42 +0530
MM_* modes let you define a convenient unit for your drawing operations.
SO If you had define something like
SetMapMode(hdc , MM_HIENGLISH);
MoveToEx(hdc ,10 ,10, NULL);
LineTo(hdc , 11,10);
You basically draw a line which is .001 physical inch(again not the real
inch). This will be same as
(GetDeviceCaps(hdc , HORZRES)/GetDeviceCaps(hdc , HORZSIZE)) * .001
pixels.
Instead of multiplying like this you can use LPToDP(...) to the device space
conversion.
So the base resolution remains the same, its just the unit of drawing
measure that you change by using
SetWindowExtEx(...) and SetViewPortEx.
But if you want to change the resolution of the screen you can use
ChangeDisplaySettings(...) and specify the new screen area(horizontal and
vertical), so this will effect the mapping mode operations because
GetDeviceCaps(..,HORZRES) and GetDeviceCaps(...,VERTRES) would
change and so a physical inch would increase or decrease and so objects on
the screen would start looking smaller or bigger. Axctually the pixel
width and height had got changed as a result.
bool setScreenResolution(int width, int height, int bpp)
{
DEVMODE dmScreenSettings;
memset(&dmScreenSettings, 0, sizeof(DEVMODE));
dmScreenSettings.dmSize = sizeof(DEVMODE);
dmScreenSettings.dmPelsWidth = width;
dmScreenSettings.dmPelsHeight = height;
dmScreenSettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
if (ChangeDisplaySettings (&dmScreenSettings,0) !=
DISP_CHANGE_SUCCESSFUL)
{
return false;
} return true;
}
Thanks
vipin
"Corey Cooper" <CoreyC at InnovativeDesign dot com> wrote in message
news:eF77#WXkEHA.556@tk2msftngp13.phx.gbl...
> Correct me if I'm wrong: What you are saying is that I can calculate what
> the current DPI is using GetDeviceCaps, but I cannot programatically set
the
> DPI of a DC? If I sst the MappingMode to MM_HIENGLISH or MM_TWIPS that
will
> set the effective DPI of the DC so that fonts are rendered at a higher
> resolution won't it?
>
> How does this sound: For the moment lets assume that MM_TWIPS (or another
> MM_) is higher resolution than I would ever need, then I could ask the
View
> Class to render the text in the DC, and use StretchBlit (or an equivelent
> that interpolates better) to shrink the DC down to the size needed. That
> sound feasable doesn't it?
>
> C.
>
>
> "vipin" <vipin@nospam.com> wrote in message
> news:eVL2TwLkEHA.396@TK2MSFTNGP12.phx.gbl...
> > GetDeviceCaps(dlg.hDC , LOGPIXELSX),
> > GetDeviceCaps(dlg.hDC , LOGPIXELSY)
> > will give you the logical inch.
> >
> > Microsoft documentation gives a terminology called physical inch(Note:
> This
> > isn't the same as tht real inch)
> >
> > GetDeviceCaps(hdc , HORZRES)/GetDeviceCaps(hdc ,HORZSIZE) and
> > GetDeviceCaps(hdc , VERTRES)/GetDeviceCaps(hdc ,VERTSIZE)
> >
> > For printers, the logical inch is same as physical inch.
> > But for display it isn't. For compatibility with windows 98,
> > you should GetDeviceCaps(...) with LOGPIXELS*.
> >
> > But for consistency with the metric mapping modes, you should use the
> > physical inch as that is the resolution used internally by the metric
> > mapping modes like MM_HIEENGLISH,MM_HIMETRIC,etc.
> >
> > You can't set the DPI of the device but for screen you can set the DPI
by
> > going manually to the display properties and then
settings->Advanced->Font
> > Size.
> > For printers, it comes inbuilt with a set of fixed resolutions.
> >
> > thanks
> > vipin
> >
> >
> >
> > "Corey Cooper" <CoreyC at InnovativeDesign dot com> wrote in message
> > news:u8VdtLLkEHA.3988@tk2msftngp13.phx.gbl...
> > > I think what I need is variable DPI resolution. When the mapmode is
set
> > to
> > > MM_TWIPS, the DPI of the DC changes, is that the same as using the
> > > SetWindowExt()/SetViewportExt() functions? When a printer DC renders
a
> > > font, it uses 600DPI (for instance), but a screen DC uses something
like
> > > 72DPI. So How do I set the DPI of the DC?
> > >
> > > C.
> > >
> > >
> > > "Corey Cooper" <CoreyC at InnovativeDesign dot com> wrote in message
> > > news:Ot67qFqjEHA.3604@TK2MSFTNGP10.phx.gbl...
> > > >
> > > > I need to have a bit of text in a document in two different
viewports,
> > one
> > > > is 'normal' and the other rendered larger in a scaleable fashon. I
> have
> > > > been trying to create a memory Device Context with a Mapping mode of
> > > > MM_ANISOTROPIC, to render to, and then blit it over to my screen DC.
> > I've
> > > > tried all sorts of combinations, but can't seem to get a higher
> > resolution
> > > > version of my fonts, all I can get is big fonts with made with big
> > pixels.
> > > >
> > > > Here is the init code (note some extra lines are left in as comments
> of
> > > > variations of what I've tried as experiments):
> > > >
> > > > CDC cdcScreen;
> > > > cdcScreen.CreateDC("DISPLAY", NULL, NULL, NULL);
> > > > ResizeableDC = new CDC;
> > > > ResizeableDC->CreateCompatibleDC(&cdcScreen);
> > > > ResizableBitmap = new CBitmap;
> > > > ResizableBitmap->CreateCompatibleBitmap(&cdcScreen,
> BitmapSize.cx,
> > > > BitmapSize.cy);
> > > >
> > > > int mode = ResizeableDC->SetMapMode(MM_ANISOTROPIC);
> > > > // ResizeableDC->SetWindowExt(BitmapSize.cx/4, BitmapSize.cy/4);
> > > > //ResizeableDC->SetViewportExt(BitmapSize.cx, BitmapSize.cy);
> > > >
> > > > ResizeableDC->SelectObject(ResizableBitmap);
> > > >
> > > >
> > > > And my OnDraw routine:
> > > >
> > > > void CFLSPJDisplayView::OnDraw(CDC* pDC)
> > > > {
> > > > ResizeableDC->SetWindowExt(BitmapSize.cx, BitmapSize.cy);
> > > > ResizeableDC->SetViewportExt(BitmapSize.cx, BitmapSize.cy);
> > > > // ResizeableDC->SetViewportExt(BitmapSize.cx*4,
BitmapSize.cy*4);
> > > >
> > > > InheritedView::OnDraw(ResizeableDC);
> > > > //InheritedView::::OnDraw(pDC); // was the default
> > implimentation
> > > >
> > > > ResizeableDC->SetWindowExt(BitmapSize.cx, BitmapSize.cy);
> > > > ResizeableDC->SetViewportExt(BitmapSize.cx/4, BitmapSize.cy/4);
> > > > // ResizeableDC->SetViewportExt(BitmapSize.cx, BitmapSize.cy);
> > > >
> > > > pDC->BitBlt(0,0,BitmapSize.cx, BitmapSize.cy,
> > > > ResizeableDC,0,0,SRCCOPY);
> > > > }
> > > >
> > > >
> > > > Of course I've tried many more variations than those shown.
> > > >
> > > > What I need is text rendered at a larger size, antialiased,
separately
> > > > variable in the X and Y dimensions (not just multiplying the font
> points
> > > by
> > > > a number) and rendered into a separate DC so that instead of the
> BitBlt
> > > I'm
> > > > using above I can do a loop of AlphaBlit's to make the text image
fade
> > up
> > > on
> > > > the view window.
> > > >
> > > > Any Ideas?
> > > >
> > > > Corey Cooper
> > > >
> > > >
> > >
> > >
> >
> >
>
>
- Next message: vipin: "Re: Charmap inconsistent behaviour"
- Previous message: pango: "how to use "new" to create a Bitmap or image in GDI+"
- In reply to: Corey Cooper: "Re: Vewports and Maping Modes"
- Next in thread: Corey Cooper: "Re: Vewports and Mapping Modes"
- Reply: Corey Cooper: "Re: Vewports and Mapping Modes"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|