string ImagePath= “C:\\111.jpg”;

解决方案 »

  1.   

    不是这个问题 上面代码我打错了 string ImagePath= “C:\\111.jpg”; 是这样的
      

  2.   

     public static Image ReturnNewImage(string ImagePath,ref string newpath,string target)
            {
                Image img = null;
                try
                {
                    FileInfo f = new FileInfo(ImagePath);
                    string name = f.Name.Replace(f.Extension,"");
                    
                    FIMULTIBITMAP bitmap = FreeImage.OpenMultiBitmapEx(ImagePath);
                    FIBITMAP page = FreeImage.LockPage(bitmap, 0);                img = FreeImage.GetBitmap(page);
    代码是这样的 ImagePath 应该没有问题 这个是获取 选择路径地址
      

  3.   

    FIMULTIBITMAP bitmap = new FIMULTIBITMAP();
    FIBITMAP page= new FIBITMAP ();
    加进去试试
      

  4.   

    断点 看看 bitmap是否为空。
      

  5.   

    代码太多了,我调试的后 就这个类出错
    到 img = FreeImage.GetBitmap(page);  这里就跳异常了
      

  6.   

    加进去一样的 page值都是0
      

  7.   

    值不能为空
    参数名dib你的代码里根本没出现dib,问题根本不是出在这里,发出来有什么用
      

  8.   

    找找你的参数名是 dib的,然后check 下null. 最好debug下看看什么情况下为null的,为什么为null.
      

  9.   

    加一个@是好习惯。
    另外DIB是设备无关位图文件格式,能直接识别加载jpg文件?尝试换一张bmp位图图片试试。
      

  10.   

    通常的原因,最好不要把图片放在C盘, 现在的系统,任务不受信任的程序访问C盘根目录或是系统目录是会被拒绝的, 放到D盘吧。
      

  11.   

    FreeImage多页函数貌似不支持jpg格式,换张gif的图片试试。
      

  12.   

    上面那方法虽然没有解决,还是非常感谢大家
    我换了个方式就解决了~        public bool MergeImageFile(string file)
            {
                Image img = Image.GetInstance(file);
                img.SetAbsolutePosition(0, 0);
                Rectangle rnt = new Rectangle(img.Width, img.Height);
                doc.SetPageSize(rnt);
                doc.NewPage();
                //img.ScaleAbsolute(img.Width, img.Height);
                img.ScaleAbsolute(doc.PageSize.Width, doc.PageSize.Height);
                img.Alignment = Image.ALIGN_MIDDLE;
                doc.Add(img);
                //pdfB.AddImage(img);
                //doc.NewPage();
                return true;
            }