能否让按钮(bitbtn,speedbutton)支持png格式?

win92 2009-11-27 11:37:19
DELPHI2007中的铵钮默认只支持BMP格式,但现在很我漂亮的图片都是PNG格式的,色彩丰富且还有透明效果,可惜按钮不能直接支持这种格式,如果用图像处理软件转换成BMP,效果又会大大的失真。

有没有办法让按钮直接支持 PNG格式。
...全文
928 24 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
yaoshangchun 2011-07-08
  • 打赏
  • 举报
回复
Image image(“PNG图片路径”, TRUE);
Graphics graphics(GetDC(hWnd));
m_rect为按钮矩形区域。
const RectF destRect( (REAL)m_rect.left,
(REAL)m_rect.top,
(REAL)(m_rect.right -m_rect.left),
(REAL)(m_rect.bottom -m_rect.top));
graphics.SetPixelOffsetMode(Gdiplus::PixelOffsetModeHighQuality);//坐标转换
graphics.DrawImage(&image, destRect);
yaoshangchun 2011-07-08
  • 打赏
  • 举报
回复
Image image(m_pImgBtnData->m_pNormal, TRUE);
Graphics graphics(GetDC(hWnd));
const RectF destRect( (REAL)m_pImgBtnData->m_rect.left,
(REAL)m_pImgBtnData->m_rect.top,
(REAL)(m_pImgBtnData->m_rect.right - m_pImgBtnData->m_rect.left),
(REAL)(m_pImgBtnData->m_rect.bottom - m_pImgBtnData->m_rect.top));
graphics.SetPixelOffsetMode(Gdiplus::PixelOffsetModeHighQuality);//坐标转换
graphics.DrawImage(&image, destRect);

注意使用GDI+的链接!
lonelv 2011-03-30
  • 打赏
  • 举报
回复
lonelv@qq.com, 能否也发我一份。。。
人鱼传说 2010-01-20
  • 打赏
  • 举报
回复
45690584@qq.com, 能否发我一份。。。
win92 2009-11-29
  • 打赏
  • 举报
回复
to mwy654321 留言中发了地址。 非常感谢
无条件为你 2009-11-28
  • 打赏
  • 举报
回复
按扭上放png是没有问题的,而且一个按扭上可以放三个png,分别在鼠标放上,离开,按下,三种状态自动切换。

楼主给我发私信我收到并回复了,可惜没有留下联系方式,也未能主动联系我,否则我把控件发给你,你的问题早解决了。
yct0605 2009-11-27
  • 打赏
  • 举报
回复
用第三方控件比较好。
不得闲 2009-11-27
  • 打赏
  • 举报
回复
有专门的PNGComponent控件包
iamduo 2009-11-27
  • 打赏
  • 举报
回复
记得好像是TGraphiX,安装一下那套控件后,以后你选择Image都能选到PNG
类似的还有一个Image什么的。我忘记名字了。
以上名字不一定是,但是确实是很有名的控件。
try__again 2009-11-27
  • 打赏
  • 举报
回复
类型转一下,
用bitmap的assign方法
wintergoes 2009-11-27
  • 打赏
  • 举报
回复
用Image加载图片当按钮
无条件为你 2009-11-27
  • 打赏
  • 举报
回复
办法是有。我发给你一个第三方控件。你可以主动联系我。
或者不用第三方,直接用gdi+画上去。
bdmh 2009-11-27
  • 打赏
  • 举报
回复
找第三方的
喝口水 2009-11-27
  • 打赏
  • 举报
回复
继承一下Tspeedbutton,很容易画的
CCC的 2009-11-27
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 wintergoes 的回复:]
用Image加载图片当按钮
[/Quote]
这个办法确实可行
win92 2009-11-27
  • 打赏
  • 举报
回复
是不是有人确实可以:

speedbutton->glyph-> 可以选择png文件?

我现在只能选择bmp
iseekcode 2009-11-27
  • 打赏
  • 举报
回复
pngimage15:

TPNGButton is a really simple button component (like delphi TBitBtn) that becomes more powerful with support for png images.

This way developers may implement it, for instance, in common TToolBars to make the toolbar buttons look much better with support for png images, especially with alpha transparency since they look nice in any background.

Important: In order to use this component you must manually install pngextra.pas into delphi / c++ builder ide. To do so, follow the "Installing the Component" guideline.

win92 2009-11-27
  • 打赏
  • 举报
回复
PNGimage我一直装有,可以在image控件上显示png,我现在需要的是在按钮上使用这个图片
win92 2009-11-27
  • 打赏
  • 举报
回复
我装了个第三方的控件,IMAGE图片是可以用到PNG,只是按钮上还是不能选PNG.
lovejiajia 2009-11-27
  • 打赏
  • 举报
回复
用RC控件足够了
加载更多回复(4)

5,927

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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