如何在标签文本上找到pictureBox(在Kb中)的图像大小 [英] How do I find size of image from pictureBox (in Kb) on label text

查看:72
本文介绍了如何在标签文本上找到pictureBox(在Kb中)的图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在页面上将图片浏览到图片框中。我想在同一页面上的标签文本上计算它的大小(以Kb为单位)

解决方案

这不是我们可以回答的问题:一旦加载了图像在图片框中,唯一可用的尺寸信息是X和Y尺寸,因为基于actaul磁盘的文件大小与图像无直接关系 - 它是图像内容和保存的文件类型的函数。 / p>

许多(几乎所有)图像文件格式都使用压缩,因此文件的大小会根据您使用的格式而有所不同:JPG文件将远远小于等效的BMP文件例如。



如果要显示文件大小,则必须在从文件加载图像时将其读取并存储以供以后显示。这很简单: FileInfo类 [ ^ ]将通过Length属性为您提供。


I am browsing an image into picturebox on page. I want to calculate its size (in Kb) on label text on same page

解决方案

That's not really something that we can answer: once the image is loaded into the picture box the only size information available is the X and Y dimensions, as the actaul disk-based file size is not related directly to the image - it's a function of teh image content and the file type that it is saved in.


Many (nearly all) image file formats use compression so the size of the file will be different depending on the format you use: JPG files will be considerably smaller than the equivalent BMP file for example.


If you want to display the file size, you must read it when you load the image from the file and store it for later display. That's simple: the FileInfo class[^] will give you that, via the Length property.


这篇关于如何在标签文本上找到pictureBox(在Kb中)的图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆