本文整理汇总了C++中FXSYS_fabs函数的典型用法代码示例。如果您正苦于以下问题:C++ FXSYS_fabs函数的具体用法?C++ FXSYS_fabs怎么用?C++ FXSYS_fabs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FXSYS_fabs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ArgbEncode
FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha()
{
if (m_pDIBSource->IsOpaqueImage()) {
CFX_PathData path;
path.AppendRect(0, 0, 1, 1);
path.Transform(&m_ImageMatrix);
FX_DWORD fill_color = ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha);
m_pRenderStatus->m_pDevice->DrawPath(&path, NULL, NULL, fill_color, 0, FXFILL_WINDING);
} else {
const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask() ? m_pDIBSource : m_pDIBSource->GetAlphaMask();
if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) {
int left, top;
CFX_DIBitmap* pTransformed = pAlphaMask->TransformTo(&m_ImageMatrix, left, top);
if (pTransformed == NULL) {
return TRUE;
}
m_pRenderStatus->m_pDevice->SetBitMask(pTransformed, left, top, ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha));
delete pTransformed;
} else {
CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect();
FX_RECT image_rect = image_rect_f.GetOutterRect();
int dest_width = m_ImageMatrix.a > 0 ? image_rect.Width() : -image_rect.Width();
int dest_height = m_ImageMatrix.d > 0 ? -image_rect.Height() : image_rect.Height();
int left = dest_width > 0 ? image_rect.left : image_rect.right;
int top = dest_height > 0 ? image_rect.top : image_rect.bottom;
m_pRenderStatus->m_pDevice->StretchBitMask(pAlphaMask, left, top, dest_width, dest_height,
ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha));
}
if (m_pDIBSource != pAlphaMask) {
delete pAlphaMask;
}
}
return FALSE;
}
示例2: CGPointMake
FX_BOOL CFX_QuartzDeviceDriver::GetDIBits(CFX_DIBitmap* bitmap,
FX_INT32 left,
FX_INT32 top,
void* pIccTransform,
FX_BOOL bDEdge)
{
if (FXDC_PRINTER == _deviceClass) {
return FALSE;
}
if (bitmap->GetBPP() < 32) {
return FALSE;
}
if (!(_renderCaps | FXRC_GET_BITS)) {
return FALSE;
}
CGPoint pt = CGPointMake(left, top);
pt = CGPointApplyAffineTransform(pt, _foxitDevice2User);
CGAffineTransform ctm = CGContextGetCTM(_context);
pt.x *= FXSYS_fabs(ctm.a);
pt.y *= FXSYS_fabs(ctm.d);
CGImageRef image = CGBitmapContextCreateImage(_context);
if (NULL == image) {
return FALSE;
}
CGFloat width = (CGFloat) bitmap->GetWidth();
CGFloat height = (CGFloat) bitmap->GetHeight();
if (width + pt.x > _width) {
width -= (width + pt.x - _width);
}
if (height + pt.y > _height) {
height -= (height + pt.y - _height);
}
CGImageRef subImage = CGImageCreateWithImageInRect(image,
CGRectMake(pt.x,
pt.y,
width,
height));
CGContextRef context = createContextWithBitmap(bitmap);
CGRect rect = CGContextGetClipBoundingBox(context);
CGContextClearRect(context, rect);
CGContextDrawImage(context, rect, subImage);
CGContextRelease(context);
CGImageRelease(subImage);
CGImageRelease(image);
if (bitmap->HasAlpha()) {
for (int row = 0; row < bitmap->GetHeight(); row ++) {
FX_LPBYTE pScanline = (FX_LPBYTE)bitmap->GetScanline(row);
for (int col = 0; col < bitmap->GetWidth(); col ++) {
if (pScanline[3] > 0) {
pScanline[0] = (pScanline[0] * 255.f / pScanline[3] + .5f);
pScanline[1] = (pScanline[1] * 255.f / pScanline[3] + .5f);
pScanline[2] = (pScanline[2] * 255.f / pScanline[3] + .5f);
}
pScanline += 4;
}
}
}
return TRUE;
}
示例3: FXSYS_fabs
CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
FX_DWORD charcode,
const CFX_AffineMatrix* pMatrix,
FX_FLOAT retinaScaleX,
FX_FLOAT retinaScaleY) {
const CPDF_Type3Char* pChar = m_pFont->LoadChar(charcode);
if (!pChar || !pChar->m_pBitmap)
return nullptr;
CFX_DIBitmap* pBitmap = pChar->m_pBitmap;
CFX_AffineMatrix image_matrix, text_matrix;
image_matrix = pChar->m_ImageMatrix;
text_matrix.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, 0, 0);
image_matrix.Concat(text_matrix);
CFX_DIBitmap* pResBitmap = NULL;
int left, top;
if (FXSYS_fabs(image_matrix.b) < FXSYS_fabs(image_matrix.a) / 100 &&
FXSYS_fabs(image_matrix.c) < FXSYS_fabs(image_matrix.d) / 100) {
int top_line, bottom_line;
top_line = _DetectFirstLastScan(pBitmap, TRUE);
bottom_line = _DetectFirstLastScan(pBitmap, FALSE);
if (top_line == 0 && bottom_line == pBitmap->GetHeight() - 1) {
FX_FLOAT top_y = image_matrix.d + image_matrix.f;
FX_FLOAT bottom_y = image_matrix.f;
FX_BOOL bFlipped = top_y > bottom_y;
if (bFlipped) {
FX_FLOAT temp = top_y;
top_y = bottom_y;
bottom_y = temp;
}
pSize->AdjustBlue(top_y, bottom_y, top_line, bottom_line);
pResBitmap = pBitmap->StretchTo(
(int)(FXSYS_round(image_matrix.a) * retinaScaleX),
(int)((bFlipped ? top_line - bottom_line : bottom_line - top_line) *
retinaScaleY));
top = top_line;
if (image_matrix.a < 0) {
image_matrix.Scale(retinaScaleX, retinaScaleY);
left = FXSYS_round(image_matrix.e + image_matrix.a);
} else {
left = FXSYS_round(image_matrix.e);
}
} else {
}
}
if (pResBitmap == NULL) {
image_matrix.Scale(retinaScaleX, retinaScaleY);
pResBitmap = pBitmap->TransformTo(&image_matrix, left, top);
}
if (pResBitmap == NULL) {
return NULL;
}
CFX_GlyphBitmap* pGlyph = new CFX_GlyphBitmap;
pGlyph->m_Left = left;
pGlyph->m_Top = -top;
pGlyph->m_Bitmap.TakeOver(pResBitmap);
delete pResBitmap;
return pGlyph;
}
示例4: GetLastPoint
void CFDE_Path::AddLine(const CFX_PointF& pt1, const CFX_PointF& pt2) {
FX_PATHPOINT* pLast = GetLastPoint();
if (!pLast || FXSYS_fabs(pLast->m_PointX - pt1.x) > 0.001 ||
FXSYS_fabs(pLast->m_PointY - pt1.y) > 0.001) {
MoveTo(pt1);
}
LineTo(pt2);
}
示例5: DrawTextString
static void DrawTextString(CFX_RenderDevice* pDevice,
const CPDF_Point& pt,
CPDF_Font* pFont,
FX_FLOAT fFontSize,
CPDF_Matrix* pUser2Device,
const CFX_ByteString& str,
FX_ARGB crTextFill,
FX_ARGB crTextStroke,
int32_t nHorzScale) {
FX_FLOAT x = pt.x, y = pt.y;
pUser2Device->Transform(x, y);
if (pFont) {
if (nHorzScale != 100) {
CPDF_Matrix mt(nHorzScale / 100.0f, 0, 0, 1, 0, 0);
mt.Concat(*pUser2Device);
CPDF_RenderOptions ro;
ro.m_Flags = RENDER_CLEARTYPE;
ro.m_ColorMode = RENDER_COLOR_NORMAL;
if (crTextStroke != 0) {
CPDF_Point pt1(0, 0), pt2(1, 0);
pUser2Device->Transform(pt1.x, pt1.y);
pUser2Device->Transform(pt2.x, pt2.y);
CFX_GraphStateData gsd;
gsd.m_LineWidth =
(FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y));
CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt,
str, crTextFill, crTextStroke, &gsd,
&ro);
} else
CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt,
str, crTextFill, 0, NULL, &ro);
} else {
CPDF_RenderOptions ro;
ro.m_Flags = RENDER_CLEARTYPE;
ro.m_ColorMode = RENDER_COLOR_NORMAL;
if (crTextStroke != 0) {
CPDF_Point pt1(0, 0), pt2(1, 0);
pUser2Device->Transform(pt1.x, pt1.y);
pUser2Device->Transform(pt2.x, pt2.y);
CFX_GraphStateData gsd;
gsd.m_LineWidth =
(FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y));
CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize,
pUser2Device, str, crTextFill,
crTextStroke, &gsd, &ro);
} else
CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize,
pUser2Device, str, crTextFill, 0,
NULL, &ro);
}
}
}
示例6: _MatchFloatRange
static void _MatchFloatRange(FX_FLOAT f1, FX_FLOAT f2, int& i1, int& i2) {
int length = (int)FXSYS_ceil(f2 - f1);
int i1_1 = (int)FXSYS_floor(f1);
int i1_2 = (int)FXSYS_ceil(f1);
FX_FLOAT error1 = f1 - i1_1 + (FX_FLOAT)FXSYS_fabs(f2 - i1_1 - length);
FX_FLOAT error2 = i1_2 - f1 + (FX_FLOAT)FXSYS_fabs(f2 - i1_2 - length);
i1 = (error1 > error2) ? i1_2 : i1_1;
i2 = i1 + length;
}
示例7: GetX
FX_BOOL CBC_QRAlignmentPattern::AboutEquals(FX_FLOAT moduleSize,
FX_FLOAT i,
FX_FLOAT j) {
if ((FXSYS_fabs(i - GetY()) <= moduleSize) &&
(FXSYS_fabs(j - GetX()) <= moduleSize)) {
FX_FLOAT moduleSizeDiff = FXSYS_fabs(moduleSize - m_moduleSize);
return (moduleSizeDiff <= 1.0f) || (moduleSizeDiff / m_moduleSize <= 1.0f);
}
return FALSE;
}
示例8: FXSYS_fabs
void CFX_Matrix::MatchRect(const CFX_FloatRect& dest,
const CFX_FloatRect& src) {
FX_FLOAT fDiff = src.left - src.right;
a = FXSYS_fabs(fDiff) < 0.001f ? 1 : (dest.left - dest.right) / fDiff;
fDiff = src.bottom - src.top;
d = FXSYS_fabs(fDiff) < 0.001f ? 1 : (dest.bottom - dest.top) / fDiff;
e = dest.left - src.left * a;
f = dest.bottom - src.bottom * d;
b = 0;
c = 0;
}
示例9: AddLines
void CFDE_Path::AddPolygon(const CFX_PointsF& points) {
int32_t iCount = points.GetSize();
if (iCount < 2)
return;
AddLines(points);
const CFX_PointF* p = points.GetData();
if (FXSYS_fabs(p[0].x - p[iCount - 1].x) < 0.01f ||
FXSYS_fabs(p[0].y - p[iCount - 1].y) < 0.01f) {
LineTo(p[0]);
}
CloseFigure();
}
示例10: FXSYS_fabs
FX_BOOL CFX_ImageTransformer::Start() {
CFX_FloatRect unit_rect = m_pMatrix->GetUnitRect();
FX_RECT result_rect = unit_rect.GetClosestRect();
FX_RECT result_clip = result_rect;
if (m_pClip)
result_clip.Intersect(*m_pClip);
if (result_clip.IsEmpty())
return FALSE;
m_result = result_clip;
if (FXSYS_fabs(m_pMatrix->a) < FXSYS_fabs(m_pMatrix->b) / 20 &&
FXSYS_fabs(m_pMatrix->d) < FXSYS_fabs(m_pMatrix->c) / 20 &&
FXSYS_fabs(m_pMatrix->a) < 0.5f && FXSYS_fabs(m_pMatrix->d) < 0.5f) {
int dest_width = result_rect.Width();
int dest_height = result_rect.Height();
result_clip.Offset(-result_rect.left, -result_rect.top);
result_clip = FXDIB_SwapClipBox(result_clip, dest_width, dest_height,
m_pMatrix->c > 0, m_pMatrix->b < 0);
m_Stretcher = WrapUnique(new CFX_ImageStretcher(
&m_Storer, m_pSrc, dest_height, dest_width, result_clip, m_Flags));
m_Stretcher->Start();
m_Status = 1;
return TRUE;
}
if (FXSYS_fabs(m_pMatrix->b) < FIX16_005 &&
FXSYS_fabs(m_pMatrix->c) < FIX16_005) {
int dest_width = m_pMatrix->a > 0 ? (int)FXSYS_ceil(m_pMatrix->a)
: (int)FXSYS_floor(m_pMatrix->a);
int dest_height = m_pMatrix->d > 0 ? (int)-FXSYS_ceil(m_pMatrix->d)
: (int)-FXSYS_floor(m_pMatrix->d);
result_clip.Offset(-result_rect.left, -result_rect.top);
m_Stretcher = WrapUnique(new CFX_ImageStretcher(
&m_Storer, m_pSrc, dest_width, dest_height, result_clip, m_Flags));
m_Stretcher->Start();
m_Status = 2;
return TRUE;
}
int stretch_width = (int)FXSYS_ceil(FXSYS_sqrt2(m_pMatrix->a, m_pMatrix->b));
int stretch_height = (int)FXSYS_ceil(FXSYS_sqrt2(m_pMatrix->c, m_pMatrix->d));
CFX_Matrix stretch2dest(1.0f, 0.0f, 0.0f, -1.0f, 0.0f,
(FX_FLOAT)(stretch_height));
stretch2dest.Concat(
m_pMatrix->a / stretch_width, m_pMatrix->b / stretch_width,
m_pMatrix->c / stretch_height, m_pMatrix->d / stretch_height,
m_pMatrix->e, m_pMatrix->f);
m_dest2stretch.SetReverse(stretch2dest);
CFX_FloatRect clip_rect_f(result_clip);
clip_rect_f.Transform(&m_dest2stretch);
m_StretchClip = clip_rect_f.GetOuterRect();
m_StretchClip.Intersect(0, 0, stretch_width, stretch_height);
m_Stretcher = WrapUnique(new CFX_ImageStretcher(&m_Storer, m_pSrc,
stretch_width, stretch_height,
m_StretchClip, m_Flags));
m_Stretcher->Start();
m_Status = 3;
return TRUE;
}
示例11: CanMerge
FX_BOOL CTextBaseLine::CanMerge(CTextBaseLine* pOther)
{
FX_FLOAT inter_top, inter_bottom;
if (!GetIntersection(m_Bottom, m_Top, pOther->m_Bottom, pOther->m_Top,
inter_bottom, inter_top)) {
return FALSE;
}
FX_FLOAT inter_h = inter_top - inter_bottom;
if (inter_h < (m_Top - m_Bottom) / 2 && inter_h < (pOther->m_Top - pOther->m_Bottom) / 2) {
return FALSE;
}
FX_FLOAT dy = (FX_FLOAT)FXSYS_fabs(m_BaseLine - pOther->m_BaseLine);
for (int i = 0; i < m_TextList.GetSize(); i ++) {
CTextBox* pText = (CTextBox*)m_TextList.GetAt(i);
for (int j = 0; j < pOther->m_TextList.GetSize(); j ++) {
CTextBox* pOtherText = (CTextBox*)pOther->m_TextList.GetAt(j);
FX_FLOAT inter_left, inter_right;
if (!GetIntersection(pText->m_Left, pText->m_Right,
pOtherText->m_Left, pOtherText->m_Right, inter_left, inter_right)) {
continue;
}
FX_FLOAT inter_w = inter_right - inter_left;
if (inter_w < pText->m_SpaceWidth / 2 && inter_w < pOtherText->m_SpaceWidth / 2) {
continue;
}
if (dy >= (pText->m_Bottom - pText->m_Top) / 2 ||
dy >= (pOtherText->m_Bottom - pOtherText->m_Top) / 2) {
return FALSE;
}
}
}
return TRUE;
}
示例12: return
int32_t CBC_PDF417Reader::getMinWidth(CBC_ResultPoint* p1,
CBC_ResultPoint* p2) {
if (p1 == NULL || p2 == NULL) {
return Integer_MAX_VALUE;
}
return (int32_t)FXSYS_fabs(p1->GetX() - p2->GetX());
}
示例13: FXSYS_atan2
void CFDE_Path::ArcTo(FX_BOOL bStart,
const CFX_RectF& rect,
FX_FLOAT startAngle,
FX_FLOAT endAngle) {
FX_FLOAT rx = rect.width / 2;
FX_FLOAT ry = rect.height / 2;
FX_FLOAT cx = rect.left + rx;
FX_FLOAT cy = rect.top + ry;
FX_FLOAT alpha =
FXSYS_atan2(rx * FXSYS_sin(startAngle), ry * FXSYS_cos(startAngle));
FX_FLOAT beta =
FXSYS_atan2(rx * FXSYS_sin(endAngle), ry * FXSYS_cos(endAngle));
if (FXSYS_fabs(beta - alpha) > FX_PI) {
if (beta > alpha)
beta -= 2 * FX_PI;
else
alpha -= 2 * FX_PI;
}
FX_FLOAT half_delta = (beta - alpha) / 2;
FX_FLOAT bcp = 4.0f / 3 * (1 - FXSYS_cos(half_delta)) / FXSYS_sin(half_delta);
FX_FLOAT sin_alpha = FXSYS_sin(alpha);
FX_FLOAT sin_beta = FXSYS_sin(beta);
FX_FLOAT cos_alpha = FXSYS_cos(alpha);
FX_FLOAT cos_beta = FXSYS_cos(beta);
if (bStart)
MoveTo(CFX_PointF(cx + rx * cos_alpha, cy + ry * sin_alpha));
BezierTo(CFX_PointF(cx + rx * (cos_alpha - bcp * sin_alpha),
cy + ry * (sin_alpha + bcp * cos_alpha)),
CFX_PointF(cx + rx * (cos_beta + bcp * sin_beta),
cy + ry * (sin_beta - bcp * cos_beta)),
CFX_PointF(cx + rx * cos_beta, cy + ry * sin_beta));
}
示例14: FXSYS_fabs
void IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
CFX_RectF rtOld = m_pProperties->m_rtWidget;
m_pProperties->m_rtWidget = rect;
if (IsChild()) {
if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f ||
FXSYS_fabs(rtOld.height - rect.height) > 0.5f) {
CFWL_EvtSizeChanged ev;
ev.m_pSrcTarget = this;
ev.m_rtOld = rtOld;
ev.m_rtNew = rect;
if (IFWL_WidgetDelegate* pDelegate = GetDelegate())
pDelegate->OnProcessEvent(&ev);
}
return;
}
m_pWidgetMgr->SetWidgetRect_Native(this, rect);
}
示例15: ArgbEncode
bool CPDF_ImageRenderer::StartBitmapAlpha() {
if (m_pDIBSource->IsOpaqueImage()) {
CFX_PathData path;
path.AppendRect(0, 0, 1, 1);
path.Transform(&m_ImageMatrix);
uint32_t fill_color =
ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha);
m_pRenderStatus->m_pDevice->DrawPath(&path, nullptr, nullptr, fill_color, 0,
FXFILL_WINDING);
return false;
}
CFX_MaybeOwned<CFX_DIBSource> pAlphaMask;
if (m_pDIBSource->IsAlphaMask())
pAlphaMask = const_cast<CFX_DIBSource*>(m_pDIBSource);
else
pAlphaMask = m_pDIBSource->CloneAlphaMask();
if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f ||
FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) {
int left;
int top;
std::unique_ptr<CFX_DIBitmap> pTransformed =
pAlphaMask->TransformTo(&m_ImageMatrix, left, top);
if (!pTransformed)
return true;
m_pRenderStatus->m_pDevice->SetBitMask(
pTransformed.get(), left, top,
ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha));
return false;
}
CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect();
FX_RECT image_rect = image_rect_f.GetOuterRect();
int dest_width =
m_ImageMatrix.a > 0 ? image_rect.Width() : -image_rect.Width();
int dest_height =
m_ImageMatrix.d > 0 ? -image_rect.Height() : image_rect.Height();
int left = dest_width > 0 ? image_rect.left : image_rect.right;
int top = dest_height > 0 ? image_rect.top : image_rect.bottom;
m_pRenderStatus->m_pDevice->StretchBitMask(
pAlphaMask.Get(), left, top, dest_width, dest_height,
ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha));
return false;
}