如题。使用c# 开发。调用windows API也可以。查到一个PBMP_IMAGE_INFO的结构体。但不知道用什么方法获得它!请教高手!

解决方案 »

  1.   

    bmp文件,从第13字节数4字节是宽度,从第17字节,数4字节是高度.其他文件格式不清楚.
      

  2.   

    Size size = new Bitmap(@"d:\file01.jpg").Size;
      

  3.   

    添加文件引用。选择浏览,找到你
    X:\windows\System32\shell32.dll,添加或则个文件引用。
    代码中添加using Shell32;命名空间引用。
    public static Size GetBitmapSize(string filepath)
    {
        ShellClass shell = new ShellClass();
        Folder dir = shell.NameSpace(Path.GetDirectoryName(filepath));
        FolderItem item = dir.ParseName(Path.GetFileName(filepath));
        Match m = Regex.Match(dir.GetDetailsOf(item, -1), @"尺寸\D+(\d+)\D+(\d+)");
        return new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
    }