Community
cancel
Showing results for 
Search instead for 
Did you mean: 
jmloriot
Beginner
218 Views

logical units

On the screen, 

How do I go from "logical coordinates" (function rectangle) to "logical units" (function strectchblt).

thanks for the answer

 

0 Kudos
6 Replies
mecej4
Black Belt
191 Views

I have to confess that, in the context of this forum (Fortran programming), I do not understand your question at all!

Is it related to some graphics library or display system?

jmloriot
Beginner
161 Views

HI mecej4

I have the following program

x=100

y=100

i=rectangle($gfillinterior,int2(x),int2(y),int2(x)+100),int2(y)+100)

status=StretchBlt(hdcScreen,x,y,x+100,y+100,hDCCompatibleBitMap,1,1, bmp.bmWidth,bmp.bmHeight,SRCCOPY)

 

When executed on a screen, the upper left corner of the rectangle is not at the same position as the upper left corner of the bitmap image.

And the difference is not the same on different screens.

and I need them to be at the same position on all screens

in the documentation it says

strechtblt : x and y are n "logical units"

rectangle : x and y are in "logical coordinates"

I tried to relate "logical units" to the values of horsize and versize from getdevicecaps,

but so far I have not been able to find how to calculate the x an y in logical units from the values in logical coordinates

Thanks

Jean-Marc

Arjen_Markus
Valued Contributor III
177 Views

In the context of graphical applications, I know of viewports, world coordinates and indeed device coordinates (pixels, if you like). Like mecej4, I have difficulty to understand your question. Could you tell us more about what you are doing? (Note: logical units in the context of Fortran are most often the numbers used to identify open files ...)

andrew_4619
Honored Contributor I
166 Views

In the Windows SDK you would need to look a SetMapMode and GetMapMode as you first need to know what the logical units are.

GVautier
New Contributor II
124 Views

The code may be like that

          hdcCompatibleBitMap=createcompatibledc(hdcScreen)
          oldbmp=selectobject(hdcCompatibleBitMap,hbitmap)
          ibid=getobject(hbitmap,sizeof(bmp),loc(bmp))
          ibid=stretchblt(hdcScreen,x,y,x+100,y+100,
     s                    hdcCompatibleBitMap,0,0,bmp.bmwidth,bmp.bmheight,
     s                    SRCCOPY)
          ibid=deleteobject(selectobject(hdcCompatibleBitMap,oldbmp))
          ibid=deletedc(hdcCompatibleBitMap)
JohnNichols
Valued Contributor II
95 Views

@jmloriot  noted :: And the difference is not the same on different screens.

and I need them to be at the same position on all screens

--------------------------------------------------------------------------------------------------

If your user changes the scaling on the screen -  you can find it in settings, it makes windows forms do erratic things,  I spent most of the weekend fixing a program for this type of problem.  

As for a bitmap, that happens, sometimes you have trouble fixing it.  If you use a scaling technique on a bit map to zoom this is a common - unfixable end result.  

Reply