PB9与GDI+

namgking 2009-02-16 02:30:11
在网上查过,PB可以用GDI+,但就不知道PB9是否可以
我做了一下,发现前几个函数都没有问题
但就是用GdipLoadImageFromFile这个函数时候,返回错误
返回值为3,错误说明是OutOfMemory
不知道怎么回事,能否请各位给个解答?

代码如下

函数声明:

Function long GdiplusStartup(ref long token, ref GdiplusStartupInput inputX, long Output) Library "gdiplus.dll"
Function long GdipCreateFromHDC( ulong hdc, ref long graphics) Library "gdiplus.dll"
Function long GdiplusShutdown (ref long token) library "gdiplus.dll" alias for "GdiplusShutdown"
Function long GdipDrawImage(ref long graphics,ref long Image, real ix, real iy) Library "gdiplus.dll" alias for "GdipDrawImage"
Function long GdipLoadImageFromFile(string filename,ref Long Image) library "gdiplus.dll" alias for "GdipLoadImageFromFile"
Function long GdipDisposeImage(long Image) Library "gdiplus.dll"
FUNCTION ulong GetDC(ulong hwnd) LIBRARY "user32.dll"




long ll_Graphics
long Instance
long ll_pic
long ll_dc

blob lb_str

Char ls_str[]

long ll_j

GdiplusStartupInput gsi_data

gsi_data.gdiplusversion = 1



If GdiplusStartup(ref Instance, ref gsi_data, 0) <> 0 Then

messagebox("Error!","Error!")

return

End If

ll_Graphics = 10

ll_dc = GetDC(Handle(this))

If GdipCreateFromHDC(ll_dc, ref ll_Graphics) <> 0 then

messagebox("Error!","Error!")

return

End If

ll_pic = 10

lb_str = ToUnicode("C:\1.png")

for ll_j = 1 to len(lb_str)

ls_str[ll_j] = char(blobmid(lb_str,ll_j,1) )

Next

ll_j = GdipLoadImageFromFile(ls_str, ref ll_pic)//"C:\1.png", ref ll_pic)

MessageBox("", string(ll_j) )

//If GdipLoadImageFromFile("D:\1.png", ref ll_pic) <> 0 then
//
// Messagebox("", "223")
//
// GdiplusShutdown(ref Instance)
//
// Return
//
//End If
ll_j = GdipDrawImage(ref ll_Graphics, ref ll_pic, 0, 0)
If ll_j <> 0 then MessageBox("", string(ll_j) )

GdiplusShutdown(ref Instance)


...全文
311 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
namgking 2009-02-17
  • 打赏
  • 举报
回复
LS的
问题还是依旧啊~
AFIC 2009-02-16
  • 打赏
  • 举报
回复
Function long GdipLoadImageFromFile(string filename,ref Long Image) library "gdiplus.dll" alias for "GdipLoadImageFromFile"
定义改成
Function long GdipLoadImageFromFile(blob filename,ref Long Image) library "gdiplus.dll" alias for "GdipLoadImageFromFile"

lb_str = ToUnicode("C:\1.png")

for ll_j = 1 to len(lb_str)

ls_str[ll_j] = char(blobmid(lb_str,ll_j,1) )

Next

ll_j = GdipLoadImageFromFile(ls_str, ref ll_pic)//"C:\1.png", ref ll_pic)
改成
lb_str = ToUnicode("C:\1.png")
ll_j = GdipLoadImageFromFile(lb_str, ref ll_pic)
namgking 2009-02-16
  • 打赏
  • 举报
回复
GDI+支持PNG的,GDI不支持
不过就算换成JPG也还是返回3
AFIC 2009-02-16
  • 打赏
  • 举报
回复
gdi+貌似不支持png把,换jpg or bmp

604

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 控件与界面
社区管理员
  • 控件与界面社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧