/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
FncGetPixel BitmapReadAccess::GetPixelFunction(ScanlineFormat nFormat)
{ switch (nFormat)
{ case ScanlineFormat::N1BitMsbPal: return GetPixelForN1BitMsbPal; case ScanlineFormat::N8BitPal: return GetPixelForN8BitPal; case ScanlineFormat::N24BitTcBgr: return GetPixelForN24BitTcBgr; case ScanlineFormat::N24BitTcRgb: return GetPixelForN24BitTcRgb; case ScanlineFormat::N32BitTcAbgr:
assert(Bitmap32IsPreMultipled()); return GetPixelForN32BitTcAbgr; case ScanlineFormat::N32BitTcXbgr:
assert(!Bitmap32IsPreMultipled()); return GetPixelForN32BitTcXbgr; case ScanlineFormat::N32BitTcArgb:
assert(Bitmap32IsPreMultipled()); return GetPixelForN32BitTcArgb; case ScanlineFormat::N32BitTcXrgb:
assert(!Bitmap32IsPreMultipled()); return GetPixelForN32BitTcXrgb; case ScanlineFormat::N32BitTcBgra:
assert(Bitmap32IsPreMultipled()); return GetPixelForN32BitTcBgra; case ScanlineFormat::N32BitTcBgrx:
assert(!Bitmap32IsPreMultipled()); return GetPixelForN32BitTcBgrx; case ScanlineFormat::N32BitTcRgba:
assert(Bitmap32IsPreMultipled()); return GetPixelForN32BitTcRgba; case ScanlineFormat::N32BitTcRgbx:
assert(!Bitmap32IsPreMultipled()); return GetPixelForN32BitTcRgbx;
default: return nullptr;
}
}
FncSetPixel BitmapReadAccess::SetPixelFunction(ScanlineFormat nFormat)
{ switch (nFormat)
{ case ScanlineFormat::N1BitMsbPal: return SetPixelForN1BitMsbPal; case ScanlineFormat::N8BitPal: return SetPixelForN8BitPal; case ScanlineFormat::N24BitTcBgr: return SetPixelForN24BitTcBgr; case ScanlineFormat::N24BitTcRgb: return SetPixelForN24BitTcRgb; case ScanlineFormat::N32BitTcAbgr:
assert(Bitmap32IsPreMultipled()); return SetPixelForN32BitTcAbgr; case ScanlineFormat::N32BitTcXbgr:
assert(!Bitmap32IsPreMultipled()); return SetPixelForN32BitTcXbgr; case ScanlineFormat::N32BitTcArgb:
assert(Bitmap32IsPreMultipled()); return SetPixelForN32BitTcArgb; case ScanlineFormat::N32BitTcXrgb:
assert(!Bitmap32IsPreMultipled()); return SetPixelForN32BitTcXrgb; case ScanlineFormat::N32BitTcBgra:
assert(Bitmap32IsPreMultipled()); return SetPixelForN32BitTcBgra; case ScanlineFormat::N32BitTcBgrx:
assert(!Bitmap32IsPreMultipled()); return SetPixelForN32BitTcBgrx; case ScanlineFormat::N32BitTcRgba:
assert(Bitmap32IsPreMultipled()); return SetPixelForN32BitTcRgba; case ScanlineFormat::N32BitTcRgbx:
assert(!Bitmap32IsPreMultipled()); return SetPixelForN32BitTcRgbx;
default:
assert(false); return nullptr;
}
}
BitmapColor BitmapReadAccess::GetInterpolatedColorWithFallback(double fY, double fX, const BitmapColor& rFallback) const
{ // ask directly doubles >= 0.0 here to avoid rounded values of 0 at small negative // double values, e.g. static_cast< sal_Int32 >(-0.25) is 0, not -1, but *has* to be outside (!) if (!mpBuffer || fX < 0.0 || fY < 0.0) return rFallback;
// merge return value with right/left neighbour if (aXCol != aRetval)
aRetval.Merge(aXCol, 255 - nDeltaX);
// merge top/bottom neighbour with edge if (aYCol != aXYCol)
aYCol.Merge(aXYCol, 255 - nDeltaX);
// merge return value with already merged top/bottom neighbour if (aRetval != aYCol)
aRetval.Merge(aYCol, 255 - nDeltaY);
return aRetval;
}
BitmapColor BitmapReadAccess::GetColorWithFallback(double fY, double fX, const BitmapColor& rFallback) const
{ // ask directly doubles >= 0.0 here to avoid rounded values of 0 at small negative // double values, e.g. static_cast< sal_Int32 >(-0.25) is 0, not -1, but *has* to be outside (!) if (!mpBuffer || fX < 0.0 || fY < 0.0) return rFallback;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.