var fd = new FrameDimension(image.FrameDimensionsList[0]);
for (int i = 2; i < image.GetFrameCount(fd); i+=2)
{
using (MemoryStream oMemoryStream = new MemoryStream())
using (MemoryStream oMemoryStream2 = new MemoryStream())
{
image.SelectActiveFrame(fd, i);
image.Save(oMemoryStream, ImageFormat.Tiff);
System.Drawing.Image tiff = System.Drawing.Image.FromStream(oMemoryStream);
Encoder encoder = Encoder.SaveFlag;
ImageCodecInfo encoderInfo = ImageCodecInfo.GetImageEncoders().First(a => a.MimeType == "image/tiff");
EncoderParameters encoderParameters = new EncoderParameters(1);
encoderParameters.Param[0] = new EncoderParameter(encoder, (long)EncoderValue.MultiFrame);
tiff.Save(oMemoryStream2, encoderInfo, encoderParameters);
encoderParameters.Param[0] = new EncoderParameter(encoder, (long)EncoderValue.FrameDimensionPage);
image.SelectActiveFrame(fd, i+1);
image.Save(oMemoryStream, ImageFormat.Tiff);
System.Drawing.Image tiff2 = System.Drawing.Image.FromStream(oMemoryStream);
tiff.SaveAdd(tiff2, encoderParameters);
encoderParameters.Param[0] = new EncoderParameter(encoder, (long)EncoderValue.Flush);
tiff.SaveAdd(encoderParameters); // 此時 oMemoryStream2 即為合併的圖檔
}
}
訂閱:
張貼留言 (Atom)
vue3-simple-alert 學習心得
官網 顯示提示輸入訊息並於按下確定時檢查是否有輸入,防止未輸入就按確定,且和按取消用不同邏輯處理 VueSimpleAlert.fire({ title: '請輸入原因', input: 'text', showCancel...
-
1. 設定檔案下載儲存位置為 C:\Users\%username%\AppData\Local\Google\Chrome\User Data\Default\Cache 2. 勾選"下載每個檔案前詢問儲存位置" 3. 針對不要下載的檔案類型於第一...
-
自動設定欄寬 sheet.Cells.AutoFitColumns(3, 20); // 必須設定 min 跟 max 才會正常作用 凍結欄位 sheet.View.FreezePanes(4, 4); 標題列 ws.PrinterSettings.RepeatRo...
-
使用 FreeSpire.XLS ... ep.Save(); using (var workbook = new Workbook()) using (var memStream = new MemoryStream()) { workbook.LoadFromSt...
沒有留言:
張貼留言