条形码阅读器和创建文件夹 [英] Barcode Reader and create Folder

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

问题描述

嗨专家,我正在开发一个名为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

推荐答案

TIffBitmapDecoder [ ^ ]有一个框架属性,可用于提取页面。如你所说,你有条码阅读器代码。所以你只需要逐个解析框架,然后根据你在框架上扫描的代码将框架作为单个图像保存在你想要的文件夹中。



[更新]

请参阅以下代码。有一个地方可以让您的条形码识别部分陷入困境。请注意,虽然它是一个控制台应用程序,但我使用的是几个WPF工具,因此您需要参考一些WPF相关的框架组合 - 当然它可以使用Windows窗体也是。

TIffBitmapDecoder[^] has a frames property you can use to extract pages. As you said you have the barcode reader code. So yo simply have to parse the frames one by one, and save the frame as individual image in the folder you want based on the code you scan on the frame.

[Update]
See following code. There is a place where you can pit your barcode recognition part in. Please not, that although it is a console application, I am using several WPF tools, thus you will need to reference some WPF related framework assamblies - of course it will work with Windows Forms too.
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);
				}
			}			
		}
	}
}


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆