Gdiplus::Pen* CFDE_GdiDevice::CreateGdiPen(IFDE_Pen* pPen, FX_FLOAT fPenWidth) { if (pPen == NULL || fPenWidth < 0.01f) { return NULL; } Gdiplus::Pen* pGdiPen = NULL; switch (pPen->GetType()) { case FDE_PENTYPE_SolidColor: { Gdiplus::Color gdiColor((Gdiplus::ARGB)pPen->GetColor()); pGdiPen = new Gdiplus::Pen(gdiColor, fPenWidth); } break; case FDE_PENTYPE_HatchBrush: case FDE_PENTYPE_TextureBrush: case FDE_PENTYPE_LinearGradient: { Gdiplus::Brush* pGdiBrush = CreateGdiBrush(pPen->GetBrush()); if (pGdiBrush) { pGdiPen = new Gdiplus::Pen(pGdiBrush, fPenWidth); } } break; } if (pGdiPen) { CFX_FloatArray dashArray; pPen->GetDashArray(dashArray); pGdiPen->SetDashPattern(dashArray.GetData(), dashArray.GetSize()); pGdiPen->SetDashOffset(pPen->GetDashPhase()); pGdiPen->SetDashStyle((Gdiplus::DashStyle)pPen->GetDashStyle()); pGdiPen->SetStartCap((Gdiplus::LineCap)pPen->GetLineCap()); pGdiPen->SetEndCap((Gdiplus::LineCap)pPen->GetLineCap()); pGdiPen->SetLineJoin((Gdiplus::LineJoin)pPen->GetLineJoin()); pGdiPen->SetMiterLimit(pPen->GetMiterLimit()); } return pGdiPen; }
CBC_CommonBitMatrix* CBC_QRGridSampler::SampleGrid(CBC_CommonBitMatrix* image, int32_t dimensionX, int32_t dimensionY, FX_FLOAT p1ToX, FX_FLOAT p1ToY, FX_FLOAT p2ToX, FX_FLOAT p2ToY, FX_FLOAT p3ToX, FX_FLOAT p3ToY, FX_FLOAT p4ToX, FX_FLOAT p4ToY, FX_FLOAT p1FromX, FX_FLOAT p1FromY, FX_FLOAT p2FromX, FX_FLOAT p2FromY, FX_FLOAT p3FromX, FX_FLOAT p3FromY, FX_FLOAT p4FromX, FX_FLOAT p4FromY, int32_t& e) { CBC_AutoPtr<CBC_CommonPerspectiveTransform> transform( CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral( p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY)); CBC_CommonBitMatrix* tempBitM = new CBC_CommonBitMatrix(); tempBitM->Init(dimensionX, dimensionY); CBC_AutoPtr<CBC_CommonBitMatrix> bits(tempBitM); CFX_FloatArray points; points.SetSize(dimensionX << 1); for (int32_t y = 0; y < dimensionY; y++) { int32_t max = points.GetSize(); FX_FLOAT iValue = (FX_FLOAT)(y + 0.5f); int32_t x; for (x = 0; x < max; x += 2) { points[x] = (FX_FLOAT)((x >> 1) + 0.5f); points[x + 1] = iValue; } transform->TransformPoints(&points); CheckAndNudgePoints(image, &points, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); for (x = 0; x < max; x += 2) { if (image->Get((int32_t)points[x], (int32_t)points[x + 1])) { bits->Set(x >> 1, y); } } }
int32_t CBC_PDF417CodewordDecoder::getClosestDecodedValue( CFX_Int32Array& moduleBitCount) { int32_t bitCountSum = CBC_PDF417Common::getBitCountSum(moduleBitCount); CFX_FloatArray bitCountRatios; bitCountRatios.SetSize(CBC_PDF417Common::BARS_IN_MODULE); for (int32_t i = 0; i < bitCountRatios.GetSize(); i++) { bitCountRatios[i] = moduleBitCount.GetAt(i) / (FX_FLOAT)bitCountSum; } FX_FLOAT bestMatchError = std::numeric_limits<int32_t>::max(); int32_t bestMatch = -1; for (int32_t j = 0; j < SYMBOL_TABLE_Length; j++) { FX_FLOAT error = 0.0f; for (int32_t k = 0; k < CBC_PDF417Common::BARS_IN_MODULE; k++) { FX_FLOAT diff = RATIOS_TABLE[j][k] - bitCountRatios[k]; error += diff * diff; } if (error < bestMatchError) { bestMatchError = error; bestMatch = CBC_PDF417Common::SYMBOL_TABLE[j]; } } return bestMatch; }
int32_t CBC_HighLevelEncoder::lookAheadTest(CFX_WideString msg, int32_t startpos, int32_t currentMode) { if (startpos >= msg.GetLength()) { return currentMode; } CFX_FloatArray charCounts; if (currentMode == ASCII_ENCODATION) { charCounts.Add(0); charCounts.Add(1); charCounts.Add(1); charCounts.Add(1); charCounts.Add(1); charCounts.Add(1.25f); } else { charCounts.Add(1); charCounts.Add(2); charCounts.Add(2); charCounts.Add(2); charCounts.Add(2); charCounts.Add(2.25f); charCounts[currentMode] = 0; } int32_t charsProcessed = 0; while (TRUE) { if ((startpos + charsProcessed) == msg.GetLength()) { FX_DWORD min = std::numeric_limits<int32_t>::max(); CFX_ByteArray mins; mins.SetSize(6); CFX_Int32Array intCharCounts; intCharCounts.SetSize(6); min = findMinimums(charCounts, intCharCounts, min, mins); int32_t minCount = getMinimumCount(mins); if (intCharCounts[ASCII_ENCODATION] == min) { return ASCII_ENCODATION; } if (minCount == 1 && mins[BASE256_ENCODATION] > 0) { return BASE256_ENCODATION; } if (minCount == 1 && mins[EDIFACT_ENCODATION] > 0) { return EDIFACT_ENCODATION; } if (minCount == 1 && mins[TEXT_ENCODATION] > 0) { return TEXT_ENCODATION; } if (minCount == 1 && mins[X12_ENCODATION] > 0) { return X12_ENCODATION; } return C40_ENCODATION; } FX_WCHAR c = msg.GetAt(startpos + charsProcessed); charsProcessed++; if (isDigit(c)) { charCounts[ASCII_ENCODATION] += 0.5; } else if (isExtendedASCII(c)) { charCounts[ASCII_ENCODATION] = (FX_FLOAT)ceil(charCounts[ASCII_ENCODATION]); charCounts[ASCII_ENCODATION] += 2; } else { charCounts[ASCII_ENCODATION] = (FX_FLOAT)ceil(charCounts[ASCII_ENCODATION]); charCounts[ASCII_ENCODATION]++; } if (isNativeC40(c)) { charCounts[C40_ENCODATION] += 2.0f / 3.0f; } else if (isExtendedASCII(c)) { charCounts[C40_ENCODATION] += 8.0f / 3.0f; } else { charCounts[C40_ENCODATION] += 4.0f / 3.0f; } if (isNativeText(c)) { charCounts[TEXT_ENCODATION] += 2.0f / 3.0f; } else if (isExtendedASCII(c)) { charCounts[TEXT_ENCODATION] += 8.0f / 3.0f; } else { charCounts[TEXT_ENCODATION] += 4.0f / 3.0f; } if (isNativeX12(c)) { charCounts[X12_ENCODATION] += 2.0f / 3.0f; } else if (isExtendedASCII(c)) { charCounts[X12_ENCODATION] += 13.0f / 3.0f; } else { charCounts[X12_ENCODATION] += 10.0f / 3.0f; } if (isNativeEDIFACT(c)) { charCounts[EDIFACT_ENCODATION] += 3.0f / 4.0f; } else if (isExtendedASCII(c)) { charCounts[EDIFACT_ENCODATION] += 17.0f / 4.0f; } else { charCounts[EDIFACT_ENCODATION] += 13.0f / 4.0f; } if (isSpecialB256(c)) { charCounts[BASE256_ENCODATION] += 4; } else { charCounts[BASE256_ENCODATION]++; } if (charsProcessed >= 4) { CFX_Int32Array intCharCounts; intCharCounts.SetSize(6); CFX_ByteArray mins; mins.SetSize(6); findMinimums(charCounts, intCharCounts, std::numeric_limits<int32_t>::max(), mins); int32_t minCount = getMinimumCount(mins); if (intCharCounts[ASCII_ENCODATION] < intCharCounts[BASE256_ENCODATION] && intCharCounts[ASCII_ENCODATION] < intCharCounts[C40_ENCODATION] && intCharCounts[ASCII_ENCODATION] < intCharCounts[TEXT_ENCODATION] && intCharCounts[ASCII_ENCODATION] < intCharCounts[X12_ENCODATION] && intCharCounts[ASCII_ENCODATION] < intCharCounts[EDIFACT_ENCODATION]) { return ASCII_ENCODATION; } if (intCharCounts[BASE256_ENCODATION] < intCharCounts[ASCII_ENCODATION] || (mins[C40_ENCODATION] + mins[TEXT_ENCODATION] + mins[X12_ENCODATION] + mins[EDIFACT_ENCODATION]) == 0) { return BASE256_ENCODATION; } if (minCount == 1 && mins[EDIFACT_ENCODATION] > 0) { return EDIFACT_ENCODATION; } if (minCount == 1 && mins[TEXT_ENCODATION] > 0) { return TEXT_ENCODATION; } if (minCount == 1 && mins[X12_ENCODATION] > 0) { return X12_ENCODATION; } if (intCharCounts[C40_ENCODATION] + 1 < intCharCounts[ASCII_ENCODATION] && intCharCounts[C40_ENCODATION] + 1 < intCharCounts[BASE256_ENCODATION] && intCharCounts[C40_ENCODATION] + 1 < intCharCounts[EDIFACT_ENCODATION] && intCharCounts[C40_ENCODATION] + 1 < intCharCounts[TEXT_ENCODATION]) { if (intCharCounts[C40_ENCODATION] < intCharCounts[X12_ENCODATION]) { return C40_ENCODATION; } if (intCharCounts[C40_ENCODATION] == intCharCounts[X12_ENCODATION]) { int32_t p = startpos + charsProcessed + 1; while (p < msg.GetLength()) { FX_WCHAR tc = msg.GetAt(p); if (isX12TermSep(tc)) { return X12_ENCODATION; } if (!isNativeX12(tc)) { break; } p++; } return C40_ENCODATION; } } } } }