本文整理匯總了C#中BinaryBitmap.crop方法的典型用法代碼示例。如果您正苦於以下問題:C# BinaryBitmap.crop方法的具體用法?C# BinaryBitmap.crop怎麽用?C# BinaryBitmap.crop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BinaryBitmap
的用法示例。
在下文中一共展示了BinaryBitmap.crop方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: decode
public Result decode(BinaryBitmap image, IDictionary<DecodeHintType, object> hints)
{
int width = image.Width;
int height = image.Height;
int halfWidth = width/2;
int halfHeight = height/2;
var topLeft = image.crop(0, 0, halfWidth, halfHeight);
var result = @delegate.decode(topLeft, hints);
if (result != null)
return result;
var topRight = image.crop(halfWidth, 0, halfWidth, halfHeight);
result = @delegate.decode(topRight, hints);
if (result != null)
return result;
var bottomLeft = image.crop(0, halfHeight, halfWidth, halfHeight);
result = @delegate.decode(bottomLeft, hints);
if (result != null)
return result;
var bottomRight = image.crop(halfWidth, halfHeight, halfWidth, halfHeight);
result = @delegate.decode(bottomRight, hints);
if (result != null)
return result;
int quarterWidth = halfWidth/2;
int quarterHeight = halfHeight/2;
var center = image.crop(quarterWidth, quarterHeight, halfWidth, halfHeight);
return @delegate.decode(center, hints);
}
示例2: decode
public Result decode(BinaryBitmap image, Dictionary<DecodeHintType, Object> hints)
{
int width = image.Width;
int height = image.Height;
int halfWidth = width/2;
int halfHeight = height/2;
BinaryBitmap topLeft = image.crop(0, 0, halfWidth, halfHeight);
try
{
return delegate_Renamed.decode(topLeft, hints);
}
catch (ReaderException)
{
// continue
}
BinaryBitmap topRight = image.crop(halfWidth, 0, halfWidth, halfHeight);
try
{
return delegate_Renamed.decode(topRight, hints);
}
catch (ReaderException)
{
// continue
}
BinaryBitmap bottomLeft = image.crop(0, halfHeight, halfWidth, halfHeight);
try
{
return delegate_Renamed.decode(bottomLeft, hints);
}
catch (ReaderException)
{
// continue
}
BinaryBitmap bottomRight = image.crop(halfWidth, halfHeight, halfWidth, halfHeight);
try
{
return delegate_Renamed.decode(bottomRight, hints);
}
catch (ReaderException)
{
// continue
}
int quarterWidth = halfWidth/2;
int quarterHeight = halfHeight/2;
BinaryBitmap center = image.crop(quarterWidth, quarterHeight, halfWidth, halfHeight);
return delegate_Renamed.decode(center, hints);
}
示例3: decode
/// <summary>
/// Locates and decodes a barcode in some format within an image. This method also accepts
/// hints, each possibly associated to some data, which may help the implementation decode.
/// </summary>
/// <param name="image">image of barcode to decode</param>
/// <param name="hints">passed as a <see cref="IDictionary{TKey, TValue}"/> from <see cref="DecodeHintType"/>
/// to arbitrary data. The
/// meaning of the data depends upon the hint type. The implementation may or may not do
/// anything with these hints.</param>
/// <returns>
/// String which the barcode encodes
/// </returns>
public Result decode(BinaryBitmap image, IDictionary<DecodeHintType, object> hints)
{
int width = image.Width;
int height = image.Height;
int halfWidth = width/2;
int halfHeight = height/2;
// No need to call makeAbsolute as results will be relative to original top left here
var result = @delegate.decode(image.crop(0, 0, halfWidth, halfHeight), hints);
if (result != null)
return result;
result = @delegate.decode(image.crop(halfWidth, 0, halfWidth, halfHeight), hints);
if (result != null)
{
makeAbsolute(result.ResultPoints, halfWidth, 0);
return result;
}
result = @delegate.decode(image.crop(0, halfHeight, halfWidth, halfHeight), hints);
if (result != null)
{
makeAbsolute(result.ResultPoints, 0, halfHeight);
return result;
}
result = @delegate.decode(image.crop(halfWidth, halfHeight, halfWidth, halfHeight), hints);
if (result != null)
{
makeAbsolute(result.ResultPoints, halfWidth, halfHeight);
return result;
}
int quarterWidth = halfWidth/2;
int quarterHeight = halfHeight/2;
var center = image.crop(quarterWidth, quarterHeight, halfWidth, halfHeight);
result = @delegate.decode(center, hints);
makeAbsolute(result.ResultPoints, quarterWidth, quarterHeight);
return result;
}
示例4: doDecodeMultiple
private void doDecodeMultiple(BinaryBitmap image, IDictionary<DecodeHintType, object> hints, IList<Result> results, int xOffset, int yOffset, int currentDepth)
{
if (currentDepth > MAX_DEPTH)
{
return;
}
Result result = _delegate.decode(image, hints);
if (result == null)
return;
bool alreadyFound = false;
for (int i = 0; i < results.Count; i++)
{
Result existingResult = (Result)results[i];
if (existingResult.Text.Equals(result.Text))
{
alreadyFound = true;
break;
}
}
if (!alreadyFound)
{
results.Add(translateResultPoints(result, xOffset, yOffset));
}
ResultPoint[] resultPoints = result.ResultPoints;
if (resultPoints == null || resultPoints.Length == 0)
{
return;
}
int width = image.Width;
int height = image.Height;
float minX = width;
float minY = height;
float maxX = 0.0f;
float maxY = 0.0f;
for (int i = 0; i < resultPoints.Length; i++)
{
ResultPoint point = resultPoints[i];
float x = point.X;
float y = point.Y;
if (x < minX)
{
minX = x;
}
if (y < minY)
{
minY = y;
}
if (x > maxX)
{
maxX = x;
}
if (y > maxY)
{
maxY = y;
}
}
// Decode left of barcode
if (minX > MIN_DIMENSION_TO_RECUR)
{
doDecodeMultiple(image.crop(0, 0, (int)minX, height), hints, results, xOffset, yOffset, currentDepth + 1);
}
// Decode above barcode
if (minY > MIN_DIMENSION_TO_RECUR)
{
doDecodeMultiple(image.crop(0, 0, width, (int)minY), hints, results, xOffset, yOffset, currentDepth + 1);
}
// Decode right of barcode
if (maxX < width - MIN_DIMENSION_TO_RECUR)
{
doDecodeMultiple(image.crop((int)maxX, 0, width - (int)maxX, height), hints, results, xOffset + (int)maxX, yOffset, currentDepth + 1);
}
// Decode below barcode
if (maxY < height - MIN_DIMENSION_TO_RECUR)
{
doDecodeMultiple(image.crop(0, (int)maxY, width, height - (int)maxY), hints, results, xOffset, yOffset + (int)maxY, currentDepth + 1);
}
}
示例5: doDecodeMultiple
private void doDecodeMultiple(BinaryBitmap image, IDictionary<DecodeHintType, object> hints, IList<Result> results, int xOffset, int yOffset)
{
Result result = _delegate.decode(image, hints);
if (result == null)
return;
bool alreadyFound = false;
for (int i = 0; i < results.Count; i++)
{
Result existingResult = (Result)results[i];
if (existingResult.Text.Equals(result.Text))
{
alreadyFound = true;
break;
}
}
if (alreadyFound)
{
return;
}
results.Add(translateResultPoints(result, xOffset, yOffset));
ResultPoint[] resultPoints = result.ResultPoints;
if (resultPoints == null || resultPoints.Length == 0)
{
return;
}
int width = image.Width;
int height = image.Height;
float minX = width;
float minY = height;
float maxX = 0.0f;
float maxY = 0.0f;
for (int i = 0; i < resultPoints.Length; i++)
{
ResultPoint point = resultPoints[i];
float x = point.X;
float y = point.Y;
if (x < minX)
{
minX = x;
}
if (y < minY)
{
minY = y;
}
if (x > maxX)
{
maxX = x;
}
if (y > maxY)
{
maxY = y;
}
}
// Decode left of barcode
if (minX > MIN_DIMENSION_TO_RECUR)
{
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
doDecodeMultiple(image.crop(0, 0, (int)minX, height), hints, results, xOffset, yOffset);
}
// Decode above barcode
if (minY > MIN_DIMENSION_TO_RECUR)
{
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
doDecodeMultiple(image.crop(0, 0, width, (int)minY), hints, results, xOffset, yOffset);
}
// Decode right of barcode
if (maxX < width - MIN_DIMENSION_TO_RECUR)
{
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
doDecodeMultiple(image.crop((int)maxX, 0, width - (int)maxX, height), hints, results, xOffset + (int)maxX, yOffset);
}
// Decode below barcode
if (maxY < height - MIN_DIMENSION_TO_RECUR)
{
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
doDecodeMultiple(image.crop(0, (int)maxY, width, height - (int)maxY), hints, results, xOffset, yOffset + (int)maxY);
}
}