网页图片自动缩小代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>网页图片自动缩小代码,防止网页表格被撑破</title>
<style type="text/css">
.content-width {MARGIN: auto;WIDTH: 600px;}
.content-width img{MAX-WIDTH: 100%!important;HEIGHT: auto!important;width:expression(this.width > 600 ? "600px" : this.width)!important;}
</style>
</head>
<body>
<div class="content-width">图片路径</div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在PowerBuilder中,可以使用以下代码缩小图片: 1. 首先,导入以下库文件: ``` IMPORTS GDI32.GdipCreateBitmapFromScan0, & GDI32.GdipCreateBitmapFromGraphics, & GDI32.GdipDisposeImage, & GDI32.GdipDeleteGraphics, & GDI32.GdipGetImageGraphicsContext, & GDI32.GdipGetImageWidth, & GDI32.GdipGetImageHeight, & GDI32.GdipDrawImageRectI, & GDI32.GdipDisposeGraphics, & GDI32.GdipFree, & GDI32.GdipSetInterpolationMode, & GDI32.GdipGetImagePixelFormat, & GDI32.GdipCreateFromHDC, & GDI32.GdipDeleteCachedBitmap, & GDI32.GdipGetImageEncodersSize, & GDI32.GdipGetImageEncoders LIBRARY gdi32.dll ``` 2. 然后,可以使用以下代码片段缩小图片: ``` OLEObject ole_1 OLEObject ole_2 Graphics graphics Bitmap bitmap int width, height int newWidth, newHeight int hdc float scaleX, scaleY ole_1 = CREATE OLEObject ole_1.ConnectToNewObject('WIA.ImageFile') ole_1.LoadFile('原始图片路径') // 加载原始图片 width = ole_1.Width height = ole_1.Height // 计算缩小比例 newWidth = width / 2 newHeight = height / 2 ole_2 = CREATE OLEObject ole_2.ConnectToNewObject('WIA.Filters') ole_2.Filters.Item('Scale').Apply(ole_1, newWidth, newHeight) // 应用缩小滤镜 // 读取缩小后的图片 graphics = GdipCreateFromHDC(hdc) bitmap = GdipCreateBitmapFromGraphics(newWidth, newHeight, graphics) GdipSetInterpolationMode(graphics, 7) // 缩小图片的插值模式设置为高质量 // 绘制缩小后的图片 GdipDrawImageRectI(graphics, bitmap, 0, 0, newWidth, newHeight) // 清理内存 GdipDeleteGraphics(graphics) GdipDisposeImage(bitmap) ole_1 = NULL ole_2 = NULL ``` 以上代码使用了Windows Imaging Component (WIA)来进行图片缩小操作。可以根据实际情况调整缩小比例以及插值模式。 注意:在使用以上代码之前,请确保已经正确安装了PowerBuilder以及相关的库文件。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值