/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
// This file is available under and governed by the GNU General Public // License version 2 only, as published by the Free Software Foundation. // However, the following notice accompanied the original version of this // file: // //--------------------------------------------------------------------------------- // // Little Color Management System // Copyright (c) 1998-2022 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the Software // is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // //--------------------------------------------------------------------------------- //
// This macro return words stored as big endian #define CHANGE_ENDIAN(w) (cmsUInt16Number) ((cmsUInt16Number) ((w)<<8)|((w)>>8))
// Floor to byte, taking care of saturation
cmsINLINE cmsUInt8Number _cmsQuickSaturateByte(cmsFloat64Number d)
{
d += 0.5; if (d <= 0) return 0; if (d >= 255.0) return 255;
return (cmsUInt8Number) _cmsQuickFloorWord(d);
}
// Return the size in bytes of a given formatter static
cmsUInt32Number trueBytesSize(cmsUInt32Number Format)
{
cmsUInt32Number fmt_bytes = T_BYTES(Format);
// For double, the T_BYTES field returns zero if (fmt_bytes == 0) returnsizeof(double);
// Otherwise, it is already correct for all formats return fmt_bytes;
}
// Returns the position (x or y) of the formatter in the table of functions static int FormatterPos(cmsUInt32Number frm)
{
cmsUInt32Number b = T_BYTES(frm);
if (b == 0 && T_FLOAT(frm)) return 5; // DBL #ifndef CMS_NO_HALF_SUPPORT if (b == 2 && T_FLOAT(frm)) return 3; // HLF #endif if (b == 4 && T_FLOAT(frm)) return 4; // FLT if (b == 2 && !T_FLOAT(frm))
{ if (T_ENDIAN16(frm)) return 2; // 16SE else return 1; // 16
} if (b == 1 && !T_FLOAT(frm)) return 0; // 8 return -1; // not recognized
}
// Obtains an alpha-to-alpha function formatter static
cmsFormatterAlphaFn _cmsGetFormatterAlpha(cmsContext id, cmsUInt32Number in, cmsUInt32Number out)
{ static cmsFormatterAlphaFn FormattersAlpha[6][6] = {
// This function computes the distance from each component to the next one in bytes. static void ComputeIncrementsForChunky(cmsUInt32Number Format,
cmsUInt32Number ComponentStartingOrder[],
cmsUInt32Number ComponentPointerIncrements[])
{
cmsUInt32Number channels[cmsMAXCHANNELS];
cmsUInt32Number extra = T_EXTRA(Format);
cmsUInt32Number nchannels = T_CHANNELS(Format);
cmsUInt32Number total_chans = nchannels + extra;
cmsUInt32Number i;
cmsUInt32Number channelSize = trueBytesSize(Format);
cmsUInt32Number pixelSize = channelSize * total_chans;
// Separation is independent of starting point and only depends on channel size for (i = 0; i < extra; i++)
ComponentPointerIncrements[i] = channelSize;
// Handle do swap for (i = 0; i < total_chans; i++)
{ if (T_DOSWAP(Format)) {
channels[i] = total_chans - i - 1;
} else {
channels[i] = i;
}
}
// Handle swap first (ROL of positions), example CMYK -> KCMY | 0123 -> 3012 if (T_SWAPFIRST(Format) && total_chans > 0) {
cmsUInt32Number tmp = channels[0]; for (i = 0; i < total_chans - 1; i++)
channels[i] = channels[i + 1];
channels[total_chans - 1] = tmp;
}
// Handle size for (i = 0; i < total_chans; i++) {
channels[i] *= BytesPerPlane;
}
for (i = 0; i < extra; i++)
ComponentStartingOrder[i] = channels[i + nchannels];
}
// Dispatcher por chunky and planar RGB static void ComputeComponentIncrements(cmsUInt32Number Format,
cmsUInt32Number BytesPerPlane,
cmsUInt32Number ComponentStartingOrder[],
cmsUInt32Number ComponentPointerIncrements[])
{ if (T_PLANAR(Format)) {
// Handles extra channels copying alpha if requested by the flags void _cmsHandleExtraChannels(_cmsTRANSFORM* p, constvoid* in, void* out,
cmsUInt32Number PixelsPerLine,
cmsUInt32Number LineCount, const cmsStride* Stride)
{
cmsUInt32Number i, j, k;
cmsUInt32Number nExtra;
cmsUInt32Number SourceStartingOrder[cmsMAXCHANNELS];
cmsUInt32Number SourceIncrements[cmsMAXCHANNELS];
cmsUInt32Number DestStartingOrder[cmsMAXCHANNELS];
cmsUInt32Number DestIncrements[cmsMAXCHANNELS];
cmsFormatterAlphaFn copyValueFn;
// Make sure we need some copy if (!(p->dwOriginalFlags & cmsFLAGS_COPY_ALPHA)) return;
// Exit early if in-place color-management is occurring - no need to copy extra channels to themselves. if (p->InputFormat == p->OutputFormat && in == out) return;
// Make sure we have same number of alpha channels. If not, just return as this should be checked at transform creation time.
nExtra = T_EXTRA(p->InputFormat); if (nExtra != T_EXTRA(p->OutputFormat)) return;
¤ 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.0.44Bemerkung:
(vorverarbeitet)
¤
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 ist noch experimentell.