各位大虾帮帮忙!帮忙看下代码问题出在哪?无限感激 string ImagePath= “C:\\111.jpg”; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不是这个问题 上面代码我打错了 string ImagePath= “C:\\111.jpg”; 是这样的 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 应该没有问题 这个是获取 选择路径地址 FIMULTIBITMAP bitmap = new FIMULTIBITMAP();FIBITMAP page= new FIBITMAP ();加进去试试 断点 看看 bitmap是否为空。 代码太多了,我调试的后 就这个类出错到 img = FreeImage.GetBitmap(page); 这里就跳异常了 加进去一样的 page值都是0 值不能为空参数名dib你的代码里根本没出现dib,问题根本不是出在这里,发出来有什么用 找找你的参数名是 dib的,然后check 下null. 最好debug下看看什么情况下为null的,为什么为null. 加一个@是好习惯。另外DIB是设备无关位图文件格式,能直接识别加载jpg文件?尝试换一张bmp位图图片试试。 通常的原因,最好不要把图片放在C盘, 现在的系统,任务不受信任的程序访问C盘根目录或是系统目录是会被拒绝的, 放到D盘吧。 FreeImage多页函数貌似不支持jpg格式,换张gif的图片试试。 上面那方法虽然没有解决,还是非常感谢大家我换了个方式就解决了~ 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; } 窗体的启动参数 急!!!!!Update语句错误,很简单的,求帮忙 c# 解压/讀url 的zip 文件 怎么可以让timer 一个小时执行一次我的保存事件 关于C#调用JavaWebservice传递验证信息SoapHeader问题 DataGridView里怎么获得一个单元格的值 关于去除字符串数组中重复元素的程序 mainmenu控件中写菜单的字号太小了,如何让之变大些? C# 中的索引器和索引属性? 初始化DataGrid的问题!! C#调用command.ExecuteNonQuery() c#webbrower控件使用问题
{
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 应该没有问题 这个是获取 选择路径地址
FIBITMAP page= new FIBITMAP ();
加进去试试
到 img = FreeImage.GetBitmap(page); 这里就跳异常了
参数名dib你的代码里根本没出现dib,问题根本不是出在这里,发出来有什么用
另外DIB是设备无关位图文件格式,能直接识别加载jpg文件?尝试换一张bmp位图图片试试。
我换了个方式就解决了~ 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;
}