如何自动按原图比例缩放图片

WANGWOWUQG 2011-05-06 01:50:27
使用原图显示取得图片的长和宽,但是出现了图片失真
blob b-pic
long babynamber
if currentrow <=0 then return
dw_1.selectrow(0,false)
dw_1.selectrow(currentrow,true)
setpointer(hourglass!)
babynamber=dw_1.getitemnumber(currentrow,"babynamber")
if babynamber>=0 then
SELECTBLOB picture001 INTO :b-PIC FROM babypicture
WHERE babynamber=:babynamber USING SQLCA;
p_2.SetPicture(b-Pic)
if p_2.Width>4000 or p_2.Height>3000 then
p_1.Width=p_2.Width
p_1.Height=p_2.Width
p_1.x=2247 - p_2.Width/2
p_1.y=1500 - p_2.Height/2
else
p_1.Width=p_2.Width
p_1.Height=p_2.Width
p_1.x=2247 - p_2.Width/2
p_1.y=1500 - p_2.Height/2
end if
p_1.SetPicture(b-Pic)
end if
setpointer(arrow!)
...全文
550 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
zgx2769 2011-07-06
  • 打赏
  • 举报
回复
这个不错,我也需要,谢谢
sysummer 2011-05-26
  • 打赏
  • 举报
回复
好东西
fengxiaohan211 2011-05-23
  • 打赏
  • 举报
回复
感谢楼上的分享
yyoinge 2011-05-23
  • 打赏
  • 举报
回复
pb开发的图片尺寸缩小程序

http://download.csdn.net/source/3303749
yyoinge 2011-05-20
  • 打赏
  • 举报
回复
如果这样还不能满足你的要求,可以帮你写一个改变图片大小的程序
yyoinge 2011-05-20
  • 打赏
  • 举报
回复
保持长宽比例后应该失真的情况比较少吧,记住比例应该是按照像素比而不是pb的units比
比如取的的图片实际长为4000units,宽为3000units,现在要将图片缩放为长不超过1000,宽不超过800的大小,则应该这么写:
//p_2.width = 4000, p_2.height = 3000
long ll_pw, ll_ph, ll_pw_m, ll_ph_m
//转换为像素
ll_pw = unitstopixels(p_2.width, xunitstopixels!)
ll_ph = unitstopixels(p_2.height, yunitstopixels!)
ll_pw_m = unitstopixels(1000, xunitstopixels!)
ll_ph_m = unitstopixels(800, yunitstopixels!)
if (ll_pw / ll_ph) >= (ll_pw_m, ll_ph_m) then
ll_ph_m = ll_pw_m * (ll_ph/ll_pw) //宽为1000,高按比例改变
else
ll_pw_m = ll_ph_m * (ll_pw/ll_ph) //高为800,宽按比例改变
end if
//再转换为unit
p_1.width = pixelstounits(ll_pw_m, xpixelstounits!)
p_1.height = pixelstounits(ll_ph_m, ypixelstounits!)


WANGWOWUQG 2011-05-18
  • 打赏
  • 举报
回复
能有人叫我吗?
sybasebbs 2011-05-06
  • 打赏
  • 举报
回复
要求用户提前整好图片吧。
WANGWOWUQG 2011-05-06
  • 打赏
  • 举报
回复
各位高手帮我一下吧,万分感激!
WANGWOWUQG 2011-05-06
  • 打赏
  • 举报
回复
如果图像过大,超出窗口范围,是否出现原图的尺寸不对
yyoinge 2011-05-06
  • 打赏
  • 举报
回复
用PB处理肯定会失真的,找一找有没有其他控件可以使用

1,077

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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