本文介绍了条形码阅读器和创建文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家,我正在开发一个名为Barcode Reader和Folder Creator的Windows应用程序,使用OnBarcode.Barcode.BarcodeScanner.dll。我想从tiff文件中读取条形码并创建相应的条形码命名文件夹。在此文件夹中,我想保存特定图像(条形码匹配页面)。除了文件夹中的特殊年龄,我已经完成了所有的工作。



请帮帮我。



[由OP更新]

我已经完成了条码阅读器和文件夹创建工作。



但我需要帮助将tiff图像拆分并保存到适当的文件夹中。



例如。在tiff文件中有8页。



Page 1有条形码:ABC101

Page 2没有条形码



第3页有条形码:ABC102

Page 4没有条形码



第5页有条形码:ABC103

Page 6无条形码



第7页有条形码:ABC104

Page 8无条形码





输出:





文件夹名称:ABC101

在此拆分页面1并保存到该文件夹​​。



文件夹名称:ABC102

在此分割中第3页并保存到该文件夹​​。



反之亦然....



我希望它的现在清楚





谢谢,

Murugavel S

Hi Experts, I am developing a windows application called Barcode Reader and Folder Creator with the use of "OnBarcode.Barcode.BarcodeScanner.dll". I want to read the barcode from the tiff files and create corresponding barcode named folder. In this folder, I want to save the particular image (Barcode Matched page). I have done all the stuff except the Particular age in the folder.

Please help me out.

[Update by OP]
I have done the Barcode reader and folder creation stuff.

But i need help to split and save the tiff image into appropriate folder.

For eg. in the tiff file has 8 pages.

Page 1 has barcode : ABC101
Page 2 no Barcode

Page 3 has barcode: ABC102
Page 4 no Barcode

Page 5 has barcode: ABC103
Page 6 no Barcode

Page 7 has barcode: ABC104
Page 8 no Barcode


output:


Folder Name : ABC101
In this split the page 1 and save into that folder.

Folder Name : ABC102
In this split the page 3 and save into that folder.

and vice versa....

I hope its clear now


Thanks,
Murugavel S

推荐答案

using System;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.IO;

namespace MyNetstat
{
	class Program    
	{
		static string ExtractBarcode(BitmapSource frame)
		{
			// here comes your barcode reader
			return DateTime.Now.Ticks.ToString();
		}		
		
		static void SaveFrame(BitmapFrame frame, string rootFolder, string barcode, int frameNumber)
		{
			string path = Path.Combine(rootFolder, barcode);
			if(!Directory.Exists(path))
			{
				Directory.CreateDirectory(path);
			}
			
			PngBitmapEncoder encoder = new PngBitmapEncoder();
			FileStream stream = new FileStream(Path.Combine(path, string.Format("p{0:d7}.png", frameNumber)), FileMode.Create);
			encoder.Interlace = PngInterlaceOption.On;
            encoder.Frames.Add(frame);
            encoder.Save(stream);
		}
		
		public static void Main()
		{
			string FileName = @"d:\temp\multipage.tif";
			string root = @"d:\temp";
			
			Stream imageStreamSource = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
			TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
			
			for(int i=0; i<decoder.Frames.Count; i++)
			{
				string barcode = ExtractBarcode(decoder.Frames[i]);
				if(!string.IsNullOrWhiteSpace(barcode))
				{
					SaveFrame(decoder.Frames[i], root, barcode, i);
				}
			}			
		}
	}
}


这篇关于条形码阅读器和创建文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 08:53