PROCEDURE Rotate(ImageFile,OutName,angle)
DECLARE INTEGER GdipLoadImageFromFile IN gdiplus.DLL STRING wFilename, INTEGER @nImage
DECLARE INTEGER GdipSaveImageToFile IN gdiplus.DLL INTEGER nImage, STRING wFilename, STRING qEncoder, STRING 
DECLARE INTEGER GdipGetImageHeight IN gdiplus.dll INTEGER  img,INTEGER @ imgheight
DECLARE INTEGER GdipGetImageWidth IN gdiplus.dll INTEGER  img,INTEGER @ imgwidth
DECLARE INTEGER GdipDisposeImage IN gdiplus.dll INTEGER  img
DECLARE INTEGER GdipRotateWorldTransform IN gdiplus.dll Long,Single,long
DECLARE INTEGER GdipTranslateWorldTransform IN gdiplus.dll Long,Single,Single,long
Declare INTEGER GdipDrawImageRect IN gdiplus.dll Long,Long,Single,Single,Single,Single
DECLARE INTEGER GdipGetImageGraphicsContext IN gdiplus.DLL INTEGER,INTEGER @
DECLARE INTEGER GdipCreateBitmapFromScan0 IN gdiplus.DLL INTEGER, INTEGER, INTEGER,INTEGER,STRING @, INTEGER @
DECLARE INTEGER GdipGraphicsClear IN gdiplus.DLL long,Long
DECLARE INTEGER GdipDeleteGraphics IN GdiPlus.dll INTEGER
nGraphics=0
nImage1=0
nimage=0
GdipLoadImageFromFile(AnsiToUnCode(ImageFile),@nimage)
w=0
h=0
GdipGetImageWidth(nImage,@w)
GdipGetImageHeight(nImage,@h)
lcEncoder=0h01F47C55041AD3119A730000F81EF32E
SinAngle=SIN(DTOR(angle))
CosAngle=COS(DTOR(angle))
DO CASE
CASE angle<=90
w1=w*CosAngle+h*SinAngle
h1=h*CosAngle+w*SinAngle
w2=h*SinAngle
h2=0
CASE angle>90 AND angle<=180
w1=h*SinAngle-w*CosAngle
h1=w*SinAngle-h*CosAngle
w2=h*SinAngle-w*CosAngle
h2=-h*CosAngle
CASE angle>180 AND angle<=270
w1=-(w*CosAngle+h*SinAngle)
h1=-(h*CosAngle+w*SinAngle)
w2=-w*CosAngle
h2=-h*CosAngle-w*SinAngle
OTHERWISE
w1=w*CosAngle-h*SinAngle
h1=h*CosAngle-w*SinAngle
w2=0
h2=-w*SinAngle
ENDCASE
GdipCreateBitmapFromScan0(w1,h1,0,925707,0,@nImage1)
GdipGetImageGraphicsContext(nImage1,@nGraphics)
GdipRotateWorldTransform(nGraphics,angle,1)
GdipTranslateWorldTransform(nGraphics,w2,h2,1)
GdipGraphicsClear(nGraphics,-1)
GdipDrawImageRect(nGraphics,nImage,0,0,w,h)
GdipSaveImageToFile (nImage1, AnsiToUnCode(OutName), lcEncoder,Null)
GdipDeleteGraphics(nGraphics)
GdipDisposeImage(nImage1)
delete in
GdipDisposeImage(nImage)
PROCEDURE AnsiToUnCode(_InStr)
DECLARE Long MultiByteToWideChar In kernel32 Long iCodePage, Long dwFlags, String @ lpStr, Long iMultiByte,String @ lpWideStr, Long iWideChar
InLen=Len(_InStr)
OutLen=2*InLen+1
_OutStr=Replicate(Chr(0),OutLen)
MultiByteToWideChar(0,0,_InStr,InLen,@_OutStr,OutLen)
RETURN _OutStr

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。