|
|
|
date: Thu, 26 Jun 2008 20:04:39 +0200,
group: microsoft.public.win32.programmer.ui
back
GDI functions and scaling - Can't get it to work ....
Hello All,
I'm drawing some things (lines, circles, etc) which are described in a
(binary) file straight on the DC of my main window, and that part works o.k.
But for some reason I can't get the drawn items to scale.
I've tried to use SetWindowExtEx with or without SetViewportExtEx (without
there was some change, but not quite controllable), and SetWorldTransform
(which did not seem to have any effect.
The used OS is Win98se, and the language is Assembly
1)
call SetMapMode,[@@hDC],MM_ANISOTROPIC
mov ecx,-100
mov edx,-100
call SetWindowOrgEx,[@@hDC],ecx,edx,0
mov ecx,10000h
mov edx,10000h
call SetWindowExtEx,[@@hDC],ecx,edx,0
call SetViewportExtEx,[@@hDC],0200h,0200h,0
2) <straight from MSDN>
call SetMapMode,[@@hDC],MM_LOENGLISH
call SetGraphicsMode,[@@hDC],GM_ADVANCED
call SetWorldTransform,[@@hDC],offset rXForm
Did I miss something in either of the above ?
Regards,
Rudy Wieser
date: Thu, 26 Jun 2008 20:04:39 +0200
author: R.Wieser lable
Re: GDI functions and scaling - Can't get it to work ....
On Jun 26, 11:04 am, "R.Wieser" <addr...@not.available> wrote:
> Hello All,
>
> I'm drawing some things (lines, circles, etc) which are described in a
> (binary) file straight on the DC of my main window, and that part works o.k.
> But for some reason I can't get the drawn items to scale.
>
> I've tried to use SetWindowExtEx with or without SetViewportExtEx (without
> there was some change, but not quite controllable), and SetWorldTransform
> (which did not seem to have any effect.
>
> The used OS is Win98se, and the language is Assembly
>
> 1)
> call SetMapMode,[@@hDC],MM_ANISOTROPIC
> mov ecx,-100
> mov edx,-100
> call SetWindowOrgEx,[@@hDC],ecx,edx,0
> mov ecx,10000h
> mov edx,10000h
> call SetWindowExtEx,[@@hDC],ecx,edx,0
> call SetViewportExtEx,[@@hDC],0200h,0200h,0
>
> 2) <straight from MSDN>
> call SetMapMode,[@@hDC],MM_LOENGLISH
> call SetGraphicsMode,[@@hDC],GM_ADVANCED
> call SetWorldTransform,[@@hDC],offset rXForm
>
> Did I miss something in either of the above ?
>
> Regards,
> Rudy Wieser
Hi,
Try to use the following API to specify which device point maps
to the window origin (0,0).
SetViewportOrgEx()
Then,
SetViewportExtEx()
http://msdn.microsoft.com/en-us/library/ms533180(VS.85).aspx
Kellie.
date: Thu, 26 Jun 2008 13:34:37 -0700 (PDT)
author: Kellie Fitton
Re: GDI functions and scaling - Can't get it to work ....
Hello Kelli,
As far as I can see it just shifts the origin from its (default) 0,0
coordinates. No scaling.
FYI: I currently have *no* idea what I should use or where, as none of the
changes I made in the code made a recognisable change on the screen.
Playing around with the SetWindowExtEx arguments did give different results,
but none of it in a form I could use be able to figure out the next step.
I just tried a number of other combinations but even a simple rectangle did
not want to change size (although I could move it around a bit by changing
the origin of the window/port) but noticed that although I have to provide
the arguments as double-words (4 bytes), only the low word (2 bytes) is
used. Is that correct ?
Regards,
Rudy Wieser
Kellie Fitton schreef in berichtnieuws
42c42bae-267c-4012-b832-c04eab56b811@t54g2000hsg.googlegroups.com...
On Jun 26, 11:04 am, "R.Wieser" <addr...@not.available> wrote:
> Hello All,
>
> I'm drawing some things (lines, circles, etc) which are described in a
> (binary) file straight on the DC of my main window, and that part works
o.k.
> But for some reason I can't get the drawn items to scale.
>
> I've tried to use SetWindowExtEx with or without SetViewportExtEx (without
> there was some change, but not quite controllable), and SetWorldTransform
> (which did not seem to have any effect.
>
> The used OS is Win98se, and the language is Assembly
>
> 1)
> call SetMapMode,[@@hDC],MM_ANISOTROPIC
> mov ecx,-100
> mov edx,-100
> call SetWindowOrgEx,[@@hDC],ecx,edx,0
> mov ecx,10000h
> mov edx,10000h
> call SetWindowExtEx,[@@hDC],ecx,edx,0
> call SetViewportExtEx,[@@hDC],0200h,0200h,0
>
> 2) <straight from MSDN>
> call SetMapMode,[@@hDC],MM_LOENGLISH
> call SetGraphicsMode,[@@hDC],GM_ADVANCED
> call SetWorldTransform,[@@hDC],offset rXForm
>
> Did I miss something in either of the above ?
>
> Regards,
> Rudy Wieser
Hi,
Try to use the following API to specify which device point maps
to the window origin (0,0).
SetViewportOrgEx()
Then,
SetViewportExtEx()
http://msdn.microsoft.com/en-us/library/ms533180(VS.85).aspx
Kellie.
date: Thu, 26 Jun 2008 23:59:54 +0200
author: R.Wieser lable
Re: GDI functions and scaling - Can't get it to work ....
On Jun 26, 2:59 pm, "R.Wieser" <addr...@not.available> wrote:
> Hello Kelli,
>
> As far as I can see it just shifts the origin from its (default) 0,0
> coordinates. No scaling.
>
> FYI: I currently have *no* idea what I should use or where, as none of the
> changes I made in the code made a recognisable change on the screen.
> Playing around with the SetWindowExtEx arguments did give different results,
> but none of it in a form I could use be able to figure out the next step.
>
> I just tried a number of other combinations but even a simple rectangle did
> not want to change size (although I could move it around a bit by changing
> the origin of the window/port) but noticed that although I have to provide
> the arguments as double-words (4 bytes), only the low word (2 bytes) is
> used. Is that correct ?
>
> Regards,
> Rudy Wieser
>
Hi,
The second argument nXExtent & nYExtent specifies the maximum
logical values of the horizontal and vertical axis, thus you should
use
a float. The following article shows an ARC function written in C
language that uses the same APIs.
Another workaround is to save your graphic drawn into a bitmap
image, then use the API StretchBlt() to scale it accordingly.
http://support.microsoft.com/kb/215336
http://msdn.microsoft.com/en-us/library/ms532355(VS.85).aspx
Kellie.
date: Thu, 26 Jun 2008 20:25:14 -0700 (PDT)
author: Kellie Fitton
Re: GDI functions and scaling - Can't get it to work ....
Hello Kellie,
> The second argument nXExtent & nYExtent specifies the
> maximum logical values of the horizontal and vertical axis,
> thus you should use a float.
Are you sure ? MSDN defines them as ints, not floats
http://msdn.microsoft.com/en-us/library/ms533175(VS.85).aspx ). Currently
only SetWindowTransform seems to use floats (in a 2x3 matrix-structure).
> Another workaround is to save your graphic drawn into
> a bitmap image, then use the API StretchBlt() to scale
> it accordingly.
I've thought of that too, but would allso like to be able to allso use the
scale-while-drawing method.
Regards,
Rudy Wieser
Kellie Fitton schreef in berichtnieuws
3112dc27-9619-45ff-b973-21de09558167@w7g2000hsa.googlegroups.com...
On Jun 26, 2:59 pm, "R.Wieser" <addr...@not.available> wrote:
> > Hello Kelli,
> >
> > As far as I can see it just shifts the origin from its (default) 0,0
> > coordinates. No scaling.
> >
> > FYI: I currently have *no* idea what I should use or where, as none of
the
> > changes I made in the code made a recognisable change on the screen.
> > Playing around with the SetWindowExtEx arguments did give different
results,
> > but none of it in a form I could use be able to figure out the next
step.
> >
> > I just tried a number of other combinations but even a simple rectangle
did
> > not want to change size (although I could move it around a bit by
changing
> > the origin of the window/port) but noticed that although I have to
provide
> > the arguments as double-words (4 bytes), only the low word (2 bytes) is
> > used. Is that correct ?
> >
> > Regards,
> > Rudy Wieser
>
>
> Hi,
>
> The second argument nXExtent & nYExtent specifies the maximum
> logical values of the horizontal and vertical axis, thus you should
> use
> a float. The following article shows an ARC function written in C
> language that uses the same APIs.
>
> Another workaround is to save your graphic drawn into a bitmap
> image, then use the API StretchBlt() to scale it accordingly.
>
> http://support.microsoft.com/kb/215336
>
> http://msdn.microsoft.com/en-us/library/ms532355(VS.85).aspx
>
> Kellie.
date: Fri, 27 Jun 2008 10:03:02 +0200
author: R.Wieser lable
Re: GDI functions and scaling - Can't get it to work ....
On Jun 27, 1:03 am, "R.Wieser" <addr...@not.available> wrote:
> Hello Kellie,
>
> > The second argument nXExtent & nYExtent specifies the
> > maximum logical values of the horizontal and vertical axis,
> > thus you should use a float.
>
> Are you sure ? MSDN defines them as ints, not floats
> http://msdn.microsoft.com/en-us/library/ms533175(VS.85).aspx). Currently
> only SetWindowTransform seems to use floats (in a 2x3 matrix-structure).
>
> > Another workaround is to save your graphic drawn into
> > a bitmap image, then use the API StretchBlt() to scale
> > it accordingly.
>
> I've thought of that too, but would allso like to be able to allso use the
> scale-while-drawing method.
>
> Regards,
> Rudy Wieser
>
Hi Rudy,
Yes, using a float will accommodate for the maximum size
even though the extent parameters are defined as INT.
float extentX = 1.0;
float extentY = 0.5;
SetViewportExtEx(hDC, PicWidth * extentX, PicHeight * extentY, NULL);
By the way, the function SetWorldTransform() is not supported under
Windows 98se, it needs Windows NT based system.
http://msdn.microsoft.com/en-us/library/ms533174(VS.85).aspx
Kellie.
date: Fri, 27 Jun 2008 13:28:23 -0700 (PDT)
author: Kellie Fitton
Re: GDI functions and scaling - Can't get it to work ....
Hello Kellie,
> Yes, using a float will accommodate for the maximum size
> even though the extent parameters are defined as INT.
As far as I can tell you are looking at a so-called "silent conversion" by
the programming-language you are using ( C(++) ? ).
While searching (I did not stop to do so after I posted my question :-) ) I
found some promising code, and after some testing I got it to work.
By setting SetWindowExtEx as well as SetViewportExtEx I got a (as far as I
can tell) consistent result in regard to scaling (scaling seems to equal to
the the WindowExt divided by the ViewportExt). All of the provided values
where double-words (4 bytes).
One thing I did find "funny" though : although I defined a viewport my
drawing could extend far beyond the set boundaries. And when I (tried to)
move the viewports origin I could see the drawing shift (pretty-much the
same as when I changed the window origin), but the drawings still extended
to the very left of the window they where drawn on (ignoring the limits I
thought would have been set by te ViewportOrgEx command)
I'll have to look into that a bit more I think.
Regards,
Rudy Wieser
> Kellie Fitton schreef in berichtnieuws
5fbc3e26-19ef-477c-a782-32788222ac13@l42g2000hsc.googlegroups.com...
> On Jun 27, 1:03 am, "R.Wieser" <addr...@not.available> wrote:
> > Hello Kellie,
> >
> > > The second argument nXExtent & nYExtent specifies the
> > > maximum logical values of the horizontal and vertical axis,
> > > thus you should use a float.
> >
> > Are you sure ? MSDN defines them as ints, not floats
> > http://msdn.microsoft.com/en-us/library/ms533175(VS.85).aspx). Currently
> > only SetWindowTransform seems to use floats (in a 2x3 matrix-structure).
> >
> > > Another workaround is to save your graphic drawn into
> > > a bitmap image, then use the API StretchBlt() to scale
> > > it accordingly.
> >
> > I've thought of that too, but would allso like to be able to allso use
the
> > scale-while-drawing method.
> >
> > Regards,
> > Rudy Wieser
> >
>
> Hi Rudy,
>
> Yes, using a float will accommodate for the maximum size
> even though the extent parameters are defined as INT.
>
> float extentX = 1.0;
> float extentY = 0.5;
>
> SetViewportExtEx(hDC, PicWidth * extentX, PicHeight * extentY, NULL);
>
>
> By the way, the function SetWorldTransform() is not supported under
> Windows 98se, it needs Windows NT based system.
>
> http://msdn.microsoft.com/en-us/library/ms533174(VS.85).aspx
>
> Kellie.
date: Sat, 28 Jun 2008 02:53:43 +0200
author: R.Wieser lable
|
|