各位大侠帮帮忙,用VFP在一张图片中写字,字体怎么旋转呢?如图“光盘编号”、”盛世天明” 105C

图片说明
Erase test.png
Declare Integer GdipDrawString In GDIPlus.Dll Long graphics,String Str,Long Length,Long thefont,String @layoutRect,Long StringFormat,Long brush
Declare Integer GdipCreateStringFormat In GDIPlus.Dll Integer formatAttributes,Integer Language,Integer @nFormat
Declare Integer GdipDeleteStringFormat In GDIPlus.Dll Long nFormat
Declare Integer GdipCreateFont In GDIPlus.Dll Integer fontFamily,Single emSize,Integer fntstyle,Integer unit,Integer @fnt
Declare Integer GdipDeleteFont In GDIPlus.Dll Integer fnt
Declare Integer GdipCreateSolidFill In GDIPlus.Dll Integer ARGBcolor,Integer @brush
Declare Integer GdipDeleteGraphics In GDIPlus.Dll Integer graphics
Declare Integer GdipDeleteBrush In GDIPlus.Dll Integer brush
Declare Integer GdipCreateFontFamilyFromName In GDIPlus.Dll String familyname,Integer FontCollection,Integer @FontFamily
Declare Integer GdipDeleteFontFamily In GDIPlus.Dll Integer FontFamily
Declare Integer GdipCreateFromHWND In GDIPlus.Dll Integer hWind,Integer @graphics
Declare Integer MultiByteToWideChar In kernel32 Long iCodePage,Long dwFlags,String @ lpStr,Long iMultiByte,String @ lpWideStr,Long iWideChar
Declare Integer GdipLoadImageFromFile In GDIPlus.Dll String wFilename,Integer @nImage
Declare Integer GdipSaveImageToFile In GDIPlus.Dll Integer nImage,String wFilename,String qEncoder,Integer nEncoderParamsPtr
Declare Integer GdipGetImageGraphicsContext In GDIPlus.Dll Integer nImage,Integer @ nGraphics
Declare Integer GdipCreateHatchBrush In GDIPlus.Dll Integer hatchstyle,Integer ForeCol,Integer BackCol,Integer @brush
Declare Integer GdipGetImageHeight In GDIPlus Integer img,Integer @ imgheight
Declare Integer GdipGetImageWidth In GDIPlus Integer img,Integer @ imgwidth
Declare Integer GdipDisposeImage In GDIPlus.Dll Long nativeImage

graphics=0
nimage=0
File_Name='c:\D.PNG' &&原图(此处可以是BMP,JPG,GIF,TIF,PNG,ICO格式的文件)
GdipLoadImageFromFile(Strconv(File_Name + Chr(0),5),@nimage)
*********开始写绿色的100**********
lcText='100'
lnLen = 2 * (Len(lcText) + 1)
lcWideStr = Replicate(Chr(0),lnLen)
MultiByteToWideChar(0,0,@lcText,Len(lcText),@lcWideStr,lnLen)
tcText=lcWideStr
lcFontName='黑体'&&字体名称,必须是已注册的字体
lcFontName=Strconv(lcFontName+Chr(0),5)
lnFontFamily=0
GdipCreateFontFamilyFromName(lcFontName,0,@lnFontFamily)
lnFont=0
lnFontStyle=1&&字体类型,0默认,1加粗,2倾斜3=1+2加粗倾斜 4U 8 S
tnSize=10&&字体大小
GdipCreateFont(lnFontFamily,tnSize,lnFontStyle,3,@lnFont)
lnFormatHandle = 0
thAlignment=0&&对其格式 居左
GdipCreateStringFormat(0,0,@lnFormatHandle )
nAlign = lnFormatHandle
brush=0
ucolor1=Rgb(0,255,0)&&字体颜色
aphpi=255&&透明度
lnColor1 = CToBin(Chr(aphpi)+Left(BinToC(uColor1,'4rs'),3),'4s')
ucolor2=Rgb(0,255,0)&&字体颜色
aphpi=255&&透明度
lnColor2 = CToBin(Chr(aphpi)+Left(BinToC(uColor2,'4rs'),3),'4s')
GdipCreateHatchBrush(11,lnColor1,lnColor2,@brush)&&建立纹理刷子
x=17&&绘制文字的左上角坐标
Y=28
w=0
h=0
GdipGetImageWidth(nImage,@w)
GdipGetImageHeight(nImage,@h)
lcRectangleF=BinToC(x,'F')+BinToC(Y,'F')+BinToC(w,'F')+BinToC(h,'F')
GdipGetImageGraphicsContext (nImage,@Graphics)
GdipDrawString(Graphics,tcText,Len(lcText),lnFont,@lcRectangleF,0,brush)
*********写绿色的100结束**********

GdipDeleteFontFamily(lnFontFamily)
GdipDeleteFont(lnFont)
GdipDeleteBrush(brush)
GdipDeleteGraphics(Graphics)
GdipDeleteStringFormat(lnFormatHandle)

*********开始写红色的200**********
lcText='200'
lnLen = 2 * (Len(lcText) + 1)
lcWideStr = Replicate(Chr(0),lnLen)
MultiByteToWideChar(0,0,@lcText,Len(lcText),@lcWideStr,lnLen)
tcText=lcWideStr
lcFontName='黑体'&&字体名称,必须是已注册的字体
lcFontName=Strconv(lcFontName+Chr(0),5)
lnFontFamily=0
GdipCreateFontFamilyFromName(lcFontName,0,@lnFontFamily)
lnFont=0
lnFontStyle=1&&字体类型,0默认,1加粗,2倾斜3=1+2加粗倾斜 4U 8 S
tnSize=10&&字体大小
GdipCreateFont(lnFontFamily,tnSize,lnFontStyle,3,@lnFont)
lnFormatHandle = 0
thAlignment=0&&对其格式 居左
GdipCreateStringFormat(0,0,@lnFormatHandle )
nAlign = lnFormatHandle
brush=0
ucolor1=Rgb(255,0,0)&&字体颜色
aphpi=255&&透明度
lnColor1 = CToBin(Chr(aphpi)+Left(BinToC(uColor1,'4rs'),3),'4s')
ucolor2=Rgb(255,0,0)&&字体颜色
aphpi=255&&透明度
lnColor2 = CToBin(Chr(aphpi)+Left(BinToC(uColor2,'4rs'),3),'4s')
GdipCreateHatchBrush(11,lnColor1,lnColor2,@brush)&&建立纹理刷子
x=17&&绘制文字的左上角坐标
Y=45
w=0
h=0
GdipGetImageWidth(nImage,@w)
GdipGetImageHeight(nImage,@h)
lcRectangleF=BinToC(x,'F')+BinToC(Y,'F')+BinToC(w,'F')+BinToC(h,'F')
GdipGetImageGraphicsContext (nImage,@Graphics)
GdipDrawString(Graphics,tcText,Len(lcText),lnFont,@lcRectangleF,0,brush)
*********写红色的200结束**********
lcEncoder=0h06F47C55041AD3119A730000F81EF32E &&PNG
*lcEncoder=0h00F47C55041AD3119A730000F81EF32E &&BMP
*lcEncoder=0h01F47C55041AD3119A730000F81EF32E &&JPG
*lcEncoder=0h02F47C55041AD3119A730000F81EF32E &&GIF
*lcEncoder=0h05F47C55041AD3119A730000F81EF32E &&TIF
*lcEncoder=0h06F47C55041AD3119A730000F81EF32E &&PNG
GdipSaveImageToFile (nImage,Strconv("c:\test.png",5) + Chr(0),lcEncoder,0)
GdipDeleteFontFamily(lnFontFamily)
GdipDeleteFont(lnFont)
GdipDisposeImage(nImage)
GdipDeleteBrush(brush)
GdipDeleteGraphics(Graphics)
GdipDeleteStringFormat(lnFormatHandle)

2个回答

如果你只要转90度,那么使用的字体前面加上一个@符号就可以了。每种字体自带一个旋转90度的字体版本

weixin_35771558
weixin_35771558 @字体不行,还像不识别还是什么,没有字出来
大约 2 个月之前 回复

Visual FoxPro简称VFP,是Microsoft公司推出的数据库开发软件,用它来开发数据库,既简单又方便。Visual FoxPro源于美国Fox Software公司推出的数据库产品FoxBase,在DOS上运行,与xBase系列相容。FoxPro原来是FoxBase的加强版,最高版本曾出过2.6。之后,Fox Software被微软收购,加以发展, 使其可以在 Windows 上运行, 并且更名为 Visual FoxPro。目前最新版为 Visual FoxPro 9.0,而在学校教学和教育部门考证中还依然延用经典版的 Visual FoxPro 6.0。在桌面型数据库应用中,处理速度极快,是日常工作中的得力助手。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问