SetWorldTransform error

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
bigindie
Newbie
Newbie
Posts: 2
Joined: Wed Jan 09, 2013 2:15 pm

SetWorldTransform error

Post by bigindie »

Hi,

I am using a flavor or the BASIC programming language in Wine 1.4. I am attempting to make the SetWorldTransform call. On a PC it works fine, my image rotates all the way to 360 degrees. On Wine running the same software as on the PC my image gets smashed to a thin line and then stretches out a long box. Why is this happening? is there something I need to change in the call?

Ben
bigindie
Newbie
Newbie
Posts: 2
Joined: Wed Jan 09, 2013 2:15 pm

Re: SetWorldTransform error

Post by bigindie »

I am using a program called Liberty BASIC. Below is the code I am running. On Windows it works fine, but in Wine it does not work correctly.

www.libertybasic.com

my code

'BMP rotation example
'
'Updated code Nov 26, 2012
'Cleaned up the code
'Fixed some bugs
'
'This example shows how to
'rotate a bitmap image
'in memory and display in a graphic
'box.
'some source code converted from
'http://www.ucancode.net/Visual_C_MFC_Ex ... xample.htm
'toFloat code used from
'http://www.b6sw.com/forum/content.php?mode=hints&t=223


'w= new bitmap width
'h= new bitmap height
'for this example I just used the whole window width and height.

'rotateX=x point on new bmp to rotate image on
'rotateY=y point on new bmp to rotate image on
'These values can be changed to rotate the image on
'different points


'setup window
nomainwin

WindowWidth=400
WindowHeight=400

UpperLeftX=100
UpperLeftY=100

open "Rotate Bitmap Example" for graphics_nsb as #g
#g,"trapclose [exit]";

'get graphic window handle and dc
hWnd=hwnd(#g)
hDC=GetDC(hWnd)

pi=3.14159265

'load bmp
filedialog "Load BMP","*.bmp",loadBMP$
if loadBMP$<>"" then
loadbmp "bmp",loadBMP$
null=GetBMPInfo("bmp")
bitmapHwnd=hbmp("bmp") 'get bmp handle


'set new bitmap size using window width & height
w=WindowWidth
h=WindowHeight

xPos=int((WindowWidth-w)/2)
yPos=int((WindowHeight-h)/2)

angle=0 'start angle

'setup workspace for rotation
sourceDC=CreateCompatibleDC(hDC)
destDC=CreateCompatibleDC(hDC)

'setup fill color for bitmap
PixCol=16777215
nbrush=CreateSolidBrush(PixCol)
oldBrush=SelectObject(destDC,nbrush)
'make new bmp image
newBitmap=CreateCompatibleBitmap(hDC,w,h)


timer 40, [rotate]
end if
wait


[rotate] 'rotate sprite

scan

'convert degree to radians
radians=(2*pi*angle)/360

'set cosine and sine values using our converted degree
cosine=cos(radians)
sine=sin(radians)


'put new bitmap into dest dc
hbmOldDest=SelectObject(destDC,newBitmap)

' null=ExtFloodFill(destDC,0,0,0,1)
null=PatBlt(destDC,0,0,w,h,_PATCOPY)

'put bmp into source dc
hbmOldSource=SelectObject(sourceDC,bitmapHwnd)


'set graphcis mode of destdc to allow rotation
null=SetGraphicsMode(destDC,2)



'setup rotation struct
struct xform,_
eM11 as ulong,_
eM12 as ulong,_
eM21 as ulong,_
eM22 as ulong,_
eDx as ulong,_
eDy as ulong

'fill rotation values
xform.eM11.struct=toFloat(cosine)
xform.eM12.struct=toFloat(sine)
xform.eM21.struct=toFloat(-1*sine)
xform.eM22.struct=toFloat(cosine)

'set x y point on the new bmp you want to rotate source image on
rotateX= int(BITMAP.bmWidth.struct/2)+int((w-BITMAP.bmWidth.struct)/2)
rotateY= int(BITMAP.bmHeight.struct/2)+int((h-BITMAP.bmHeight.struct)/2)


xform.eDx.struct=toFloat(rotateX-cosine*rotateX+sine*rotateY)
xform.eDy.struct=toFloat(rotateY-cosine*rotateY-sine*rotateX)

'rotate bitmap
r=SetWorldTransform(destDC,xform)



'put our source bitmap into our dest dc
null=BitBlt(destDC,int((w-BITMAP.bmWidth.struct)/2),int((h-BITMAP.bmHeight.struct)/2),w,h,sourceDC, 0 ,0 , _SRCCOPY)

'set graphcis mode of destdc to allow rotation
null=SetGraphicsMode(destDC,1)


'release new rotated bitmap
null=SelectObject(destDC,hbmOldDest)


'put rotated bitmap into sourceDC
hbmOldSource=SelectObject(sourceDC,newBitmap)

'draw rotated bitmap onto screen into our dest dc
null=BitBlt(hDC,xPos,yPos,w,h,sourceDC,0 ,0 , _SRCCOPY)


null=SelectObject(sourceDC,hbmOldSource)

angle=angle+2

wait



[exit]
timer 0

null=DeleteObject(newBitmap)
'clean up
'release source bitmap from dc
null=SelectObject(sourceDC,hbmOldSource)'release
null=SelectObject(destDC,oldBrush)
null=DeleteObject(nbrush)
null=DeleteDC(sourcDC)
null=DeleteDC(destDC)
close #g
end



'--------------functions----------------------------------------

Function GetBMPInfo(bmp$)

bitmapHwnd=hbmp(bmp$) 'get bmp handle

'create struct for bmp info
struct BITMAP,_
bmType As long,_
bmWidth As long,_
bmHeight As long,_
bmWidthBytes As long,_
bmPlanes As word,_
bmBitsPixel As word,_
bmBits As long

structSize=Len(BITMAP.struct)'get the size of the struct:

CallDLL #gdi32, "GetObjectA",_
bitmapHwnd As ulong,_ 'handle of bitmap
structSize As long,_ 'size of struct
BITMAP As struct,_ 'name of struct
GetBMPInfo As long

End Function

Function GetPixel(hdc,xpos,ypos)
CallDll #gdi32,"GetPixel",_
hdc as Ulong,_
xpos as long,_
ypos as long,_
GetPixel as Ulong
End Function


Function SetWorldTransform(hdc,xform)
CallDLL #gdi32, "SetWorldTransform",_
hdc As ULong,_
xform As struct,_
SetWorldTransform As Long
End Function

Function SetGraphicsMode(hdc,iMode)
CallDll #gdi32,"SetGraphicsMode",_
hdc as Ulong,_
iMode as ulong,_
SetGraphicsMode as long
End Function

Function GetDC(handle)
CallDLL #user32, "GetDC", _
handle As Ulong, _
GetDC as Ulong
End Function

Function ReleaseDC(handle, hDC)
CallDLL #user32, "ReleaseDC", _
handle As Ulong, _
hDC As Ulong, _
ReleaseDC As Long
End Function

Function DeleteDC(hDC)
CallDLL #gdi32, "DeleteDC", _
hDC as Ulong, _
result as Boolean
End Function

Function CreateCompatibleDC(hDC)
CallDLL #gdi32, "CreateCompatibleDC", _
hDC as Ulong, _
CreateCompatibleDC as Ulong
End Function

Function CreateCompatibleBitmap(hDC, wMem, hMem)
CallDLL #gdi32, "CreateCompatibleBitmap", _
hDC as Ulong, _
wMem as Long, _
hMem as Long, _
CreateCompatibleBitmap as Ulong
End Function

Function SelectObject(hDC, hPic)
CallDLL #gdi32, "SelectObject", _
hDC as Ulong, _
hPic as Ulong, _
SelectObject as Ulong
End Function

Function BitBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSource, xSource, ySource, ROP)
CallDLL #gdi32, "BitBlt", _
hdcDest as Ulong, _
xDest as Long, _
yDest as Long, _
wDest as Long, _
hDest as Long, _
hdcSource as Ulong, _
xSource as Long, _
ySource as Long, _
ROP as Ulong, _
result as Boolean
End Function

Function toFloat( R8 )
Open "oleaut32" For DLL As #oleaut32
'-- Converts a 64-bit Double to a 32-bit number.
Struct local1, R4 As ULong
CallDLL #oleaut32, "VarR4FromR8", _
R8 As Double, local1 As Struct, _
ret As Long
toFloat = local1.R4.struct
close #oleaut32
End Function


Function DeleteObject(objHandle)
CallDll #gdi32,"DeleteObject",_
objHandle as Ulong,_
DeleteObject as long
End Function

Function PatBlt(hdc,nx,ny,nw,nh,style)
CallDll #gdi32,"PatBlt",_
hdc as Ulong,_
nx as long,_
ny as long,_
nw as long,_
nh as long,_
style as ulong,_
PatBlt as boolean
End Function

Function CreateSolidBrush(bcolor)
CallDll #gdi32,"CreateSolidBrush",_
bcolor as long,_
CreateSolidBrush as Ulong
End Function
lahmbi5678
Level 7
Level 7
Posts: 823
Joined: Thu Aug 27, 2009 6:23 am

Re: SetWorldTransform error

Post by lahmbi5678 »

Please upgrade to latest wine, 1.5.21. Run from command line and post terminal output. If there's no obvious error message, file a bug.
Locked