循序~渐进 2020-01-01 16:23 采纳率: 50%
浏览 264
已结题

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

图片说明
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条回答 默认 最新

  • threenewbee 2020-01-01 23:33
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题