首页/ 接口索引/ 位图处理

bitmap.SizeWidth / SizeHeight

位图的像素尺寸(不是文档尺寸)。判断"这张图够不够大"就看它,别拿 shape.SizeWidth 当像素用。

签名

bitmap.SizeWidth / SizeHeight

说明

位图的像素尺寸(不是文档尺寸)。判断"这张图够不够大"就看它,别拿 shape.SizeWidth 当像素用。

Python 示例(可直接运行)

依赖 pywin32。示例假定 app / doc / page / layer 已就绪。 见「连接与初始化」
Python
shape = app.ActiveSelectionRange(1)

if shape.Type == 5:
    bmp = shape.Bitmap
    px_w, px_h = bmp.SizeWidth, bmp.SizeHeight

    # 按 300dpi 反算能印多大(英寸 -> 毫米)
    mm_w = px_w / bmp.ResolutionX * 25.4
    mm_h = px_h / bmp.ResolutionY * 25.4
    print("像素:", px_w, "x", px_h)
    print("300dpi 下能印:", round(mm_w, 1), "x", round(mm_h, 1), "mm")

关于本类:位图处理

位图对象挂在 shape.Bitmap 上,前提是 shape.Type == 5。分辨率、像素尺寸、颜色模式、重新采样都在这里。

同类其他接口