Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
yebuyebu authored Nov 17, 2021
1 parent aa8d026 commit 0f3054c
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 0 deletions.
6 changes: 6 additions & 0 deletions samples/UseCases/ReadDPMBarcode/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
95 changes: 95 additions & 0 deletions samples/UseCases/ReadDPMBarcode/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using System;
using Dynamsoft;
using Dynamsoft.DBR;


namespace ReadDPMBarcode
{
class Program
{
static void configReadDPMBarcode(BarcodeReader dbr)
{
// Obtain current runtime settings of instance.
PublicRuntimeSettings sts = dbr.GetRuntimeSettings();

// Set expected barcode formats.
// Generally, the most common dpm barcode is datamatrix or qrcode
sts.BarcodeFormatIds = (int)(EnumBarcodeFormat.BF_DATAMATRIX | EnumBarcodeFormat.BF_QR_CODE);

// Set grayscale transformation modes.
// DPM barcodes may be dark and printed on the light background, or it may be light and printed on the dark background.
// By default, the library can only locate the dark barcodes that stand on a light background. "GTM_INVERTED":The image will be transformed into inverted grayscale.
sts.FurtherModes.GrayscaleTransformationModes[0] = EnumGrayscaleTransformationMode.GTM_ORIGINAL;
sts.FurtherModes.GrayscaleTransformationModes[1] = EnumGrayscaleTransformationMode.GTM_INVERTED;

// Enable dpm modes.
// It is a parameter to control how to read direct part mark (DPM) barcodes.
sts.FurtherModes.DPMCodeReadingModes[0] = EnumDPMCodeReadingMode.DPMCRM_GENERAL;

// Apply the new settings to the instance
dbr.UpdateRuntimeSettings(sts);
}

static void outputResults(TextResult[] results)
{
if (results != null && results.Length > 0)
{
int i = 1;
foreach (TextResult result in results)
{
string barcodeFormat = result.BarcodeFormat == 0 ? result.BarcodeFormatString_2 : result.BarcodeFormatString;
Console.WriteLine("Barcode {0}:{1},{2}", i, barcodeFormat, result.BarcodeText);
i++;
}
}
else
{
Console.WriteLine("No data detected.");
}
}
static void Main(string[] args)
{
try
{
// Initialize license
/*
// By setting organization ID as "200001", a 7-day trial license will be used for license verification.
// Note that network connection is required for this license to work.
//
// When using your own license, locate the following line and specify your Organization ID.
// organizationID = "200001";
//
// If you don't have a license yet, you can request a trial from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=dotnet
*/
DMDLSConnectionParameters connectionInfo = BarcodeReader.InitDLSConnectionParameters();
connectionInfo.OrganizationID = "200001";
EnumErrorCode errorCode = BarcodeReader.InitLicenseFromDLS(connectionInfo, out string errorMsg);
if (errorCode != EnumErrorCode.DBR_SUCCESS)
{
Console.WriteLine(errorMsg);
}

// Create an instance of Barcode Reader
BarcodeReader dbr = new BarcodeReader();
TextResult[] results = null;
string fileName = "../../../../../images/dpm.jpg";

// config through PublicRuntimeSettings
configReadDPMBarcode(dbr);

// Decode barcodes from an image file by current runtime settings. The second parameter value "" means to decode through the current PublicRuntimeSettings.
results = dbr.DecodeFile(fileName, "");

// Output the barcode format and barcode text.
outputResults(results);
}
catch (Exception exp)
{
Console.WriteLine(exp.Message);
}
Console.WriteLine("Press any key to quit...");
Console.ReadKey();
}
}
}

36 changes: 36 additions & 0 deletions samples/UseCases/ReadDPMBarcode/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ReadDPMBarcode")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ReadDPMBarcode")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f08d1998-bf71-4b43-a84c-087c7ad1221d")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
52 changes: 52 additions & 0 deletions samples/UseCases/ReadDPMBarcode/ReadDPMBarcode.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F08D1998-BF71-4B43-A84C-087C7AD1221D}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ReadDPMBarcode</RootNamespace>
<AssemblyName>ReadDPMBarcode</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dynamsoft.BarcodeReader">
<HintPath>..\..\packages\Dynamsoft.DotNet.Barcode.8.8.0\lib\net40\Dynamsoft.BarcodeReader.dll</HintPath>
</Reference>
<Reference Include="DynamsoftCommon">
<HintPath>..\..\packages\Dynamsoft.DotNet.Barcode.8.8.0\lib\net40\DynamsoftCommon.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
4 changes: 4 additions & 0 deletions samples/UseCases/ReadDPMBarcode/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Dynamsoft.DotNet.Barcode" version="8.8.0" targetFramework="net472" />
</packages>

0 comments on commit 0f3054c

Please sign in to comment.