Difference between revisions of "BGRABitmap Pixel types/ru"

From Free Pascal wiki
Jump to navigationJump to search
Line 38: Line 38:
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' CombineLightness(lightness1,lightness2: Int32or64): Int32or64;</td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' CombineLightness(lightness1,lightness2: Int32or64): Int32or64;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Combines two lightnesses together. A value of 32768 is neutral. The result may exceed 65535</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Объединяет две яркости вместе. Значение 32768 является нейтральным. Результат может превысить 65535</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' BGRAToGrayscale(c: TBGRAPixel): TBGRAPixel;</td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' BGRAToGrayscale(c: TBGRAPixel): TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a color into grayscale</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Преобразует цвет в оттенки серого</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' GrayscaleToBGRA(lightness: word): TBGRAPixel;</td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' GrayscaleToBGRA(lightness: word): TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Create a gray color with the given ''lightness''</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Создает серый цвет с заданной ''яркостью''</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' MergeBGRA(c1, c2: TBGRAPixel): TBGRAPixel; '''overload''';</td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' MergeBGRA(c1, c2: TBGRAPixel): TBGRAPixel; '''overload''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Merge two colors without gamma correction</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Слияние двух цветов без гамма-коррекции</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' MergeBGRA(c1: TBGRAPixel; weight1: integer; c2: TBGRAPixel; weight2: integer): TBGRAPixel; '''overload''';</td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' MergeBGRA(c1: TBGRAPixel; weight1: integer; c2: TBGRAPixel; weight2: integer): TBGRAPixel; '''overload''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Merge two colors without gamma correction. ''weight1'' and ''weight2'' indicates the weight of the color barycentre</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Слияние двух цветов без гамма-коррекции. ''weight1'' и ''weight2'' указывает на вес цветового барицентра</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' MergeBGRAWithGammaCorrection(c1: TBGRAPixel; weight1: byte; c2: TBGRAPixel; weight2: byte): TBGRAPixel;</td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' MergeBGRAWithGammaCorrection(c1: TBGRAPixel; weight1: byte; c2: TBGRAPixel; weight2: byte): TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Merge two colors with gamma correction. ''weight1'' and ''weight2'' indicates the weight of the color barycentre</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Слияние двух цветов с гамма-коррекцией. ''weight1'' и ''weight2'' указывает на вес цветового барицентра</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' ColorToBGRA(color: TColor): TBGRAPixel; '''overload''';</td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' ColorToBGRA(color: TColor): TBGRAPixel; '''overload''';</td></tr>

Revision as of 22:45, 21 December 2018

Template:MenuTranslate

Список типов пикселей и функций библиотеки BGRABitmap. Они предоставляются модулем BGRABitmapTypes.

Типы пикселей и функции

PBGRAPixel = ^TBGRAPixel;
Указатель для прямого доступа к пикселям. Данные хранятся в виде последовательности TBGRAPixel. См. BGRABitmap tutorial 4
TBGRAPixel = packed record blue, green, red, alpha: byte;
Каждый пиксель представляет собой последовательность из 4 байтов, содержащую синий, зеленый, красный и альфа-канал. Диапазон значений от 0 до 255, цвет в цветовом пространстве sRGB. Альфа-значение: 0 - прозрачно, 255 - непрозрачно. В растровых данных, когда пиксель полностью прозрачен, значения RGB должны быть установлены на ноль.
function BGRA(red, green, blue, alpha: byte): TBGRAPixel; overload; inline;
Создает пиксель с заданными значениями RGBA
function BGRA(red, green, blue: byte): TBGRAPixel; overload; inline;
Создает непрозрачный пиксель с заданными значениями RGB
operator = (const c1, c2: TBGRAPixel): boolean; inline;
Проверяет, равны ли два пикселя. Если они оба прозрачны, значения RGB игнорируются
function GetIntensity(c: TBGRAPixel): word; inline;
Возвращает интенсивность пикселя. Интенсивность - это максимальное значение, достигаемое любым компонентом
function SetIntensity(c: TBGRAPixel; intensity: word): TBGRAPixel;
Устанавливает интенсивность пикселя
function GetLightness(c: TBGRAPixel): word;
Возвращает свечение пикселя. Свечение - это воспринимаемая яркость, 0 - черный, а 65535 - белый.
function SetLightness(c: TBGRAPixel; lightness: word): TBGRAPixel;
Возвращает свечение пикселя
function ApplyLightnessFast(color: TBGRAPixel; lightness: word): TBGRAPixel; inline;
Быстро устанавливает свечение, уменьшая в сторону черного, если lightness меньше 32768, и уменьшая в сторону белого, если lightness больше 32768
function ApplyIntensityFast(color: TBGRAPixel; lightness: longword): TBGRAPixel;
Быстро устанавливает интенсивность, уменьшая в сторону черного, если lightness меньше 32768, и умножая все составляющие, если lightness больше 32768. В случае насыщения, она исчезает в сторону белого
function CombineLightness(lightness1,lightness2: Int32or64): Int32or64;
Объединяет две яркости вместе. Значение 32768 является нейтральным. Результат может превысить 65535
function BGRAToGrayscale(c: TBGRAPixel): TBGRAPixel;
Преобразует цвет в оттенки серого
function GrayscaleToBGRA(lightness: word): TBGRAPixel;
Создает серый цвет с заданной яркостью
function MergeBGRA(c1, c2: TBGRAPixel): TBGRAPixel; overload;
Слияние двух цветов без гамма-коррекции
function MergeBGRA(c1: TBGRAPixel; weight1: integer; c2: TBGRAPixel; weight2: integer): TBGRAPixel; overload;
Слияние двух цветов без гамма-коррекции. weight1 и weight2 указывает на вес цветового барицентра
function MergeBGRAWithGammaCorrection(c1: TBGRAPixel; weight1: byte; c2: TBGRAPixel; weight2: byte): TBGRAPixel;
Слияние двух цветов с гамма-коррекцией. weight1 и weight2 указывает на вес цветового барицентра
function ColorToBGRA(color: TColor): TBGRAPixel; overload;
Converts a TColor value into an opaque pixel
function ColorToBGRA(color: TColor; opacity: byte): TBGRAPixel; overload;
Converts a TColor value into a pixel with given opacity
function BGRAToColor(c: TBGRAPixel): TColor;
Converts a pixel into a TColor value, discarding the alpha value
function FPColorToBGRA(AValue: TFPColor): TBGRAPixel;
Converts a TFPColor value into a pixel. Note that even if TFPColor have 16-bit values, they are not considered as gamma expanded
function BGRAToFPColor(AValue: TBGRAPixel): TFPColor; inline;
Converts a pixel into a TFPColor
function BGRAWordDiff(c1, c2: TBGRAPixel): word;
Computes the difference (with gamma correction) between two pixels, taking into account all dimensions, including transparency. The result ranges from 0 to 65535
function BGRADiff(c1, c2: TBGRAPixel): byte;
Computes the difference (with gamma correction) between two pixels, taking into account all dimensions, including transparency. The result ranges from 0 to 255
ArrayOfTBGRAPixel = array of TBGRAPixel;
Array of pixels
function MergeBGRA(const colors: array of TBGRAPixel): TBGRAPixel; overload;
Merge given colors without gamma correction
TExpandedPixel = packed record red, green, blue, alpha: word;
Stores a gamma expanded RGB color. Values range from 0 to 65535
function GammaExpansion(c: TBGRAPixel): TExpandedPixel; inline;
Converts a pixel from sRGB to gamma expanded RGB
function GammaCompression(const ec: TExpandedPixel): TBGRAPixel; inline;
Converts a pixel from gamma expanded RGB to sRGB
function GammaCompression(red,green,blue,alpha: word): TBGRAPixel; inline;
Converts a pixel from gamma expanded RGB to sRGB
function GetIntensity(const c: TExpandedPixel): word; inline;
Returns the intensity of an gamma-expanded pixel. The intensity is the maximum value reached by any component
function SetIntensity(const c: TExpandedPixel; intensity: word): TExpandedPixel;
Sets the intensity of a gamma-expanded pixel
function GetLightness(const c: TExpandedPixel): word; inline;
Returns the lightness of an gamma-expanded pixel. The lightness is the perceived brightness, 0 being black and 65535 being white
function SetLightness(const c: TExpandedPixel; lightness: word): TExpandedPixel;
Sets the lightness of a gamma-expanded pixel
function SetLightness(const c: TExpandedPixel; lightness: word; curLightness: word): TExpandedPixel;
Sets the lightness of a gamma expanded pixel, provided you already know the current value of lightness curLightness. It is a bit faster than the previous function
function ColorImportance(ec: TExpandedPixel): word;
Returns the importance of the color. It is similar to saturation in HSL colorspace, except it is gamma corrected. A value of zero indicates a black/gray/white, and a value of 65535 indicates a bright color
function MergeBGRA(ec1, ec2: TExpandedPixel): TExpandedPixel; overload;
Merge two gamma expanded pixels (so taking into account gamma correction)
function ExpandedDiff(ec1, ec2: TExpandedPixel): word;
Computes the difference (with gamma correction) between two pixels, taking into account all dimensions, including transparency. The result ranges from 0 to 65535
THSLAPixel = packed record
Pixel color defined in HSL colorspace. Values range from 0 to 65535
hue: word;
Hue of the pixel. Extremum values 0 and 65535 are red
saturation: word;
Saturation of the color. 0 is gray and 65535 is the brightest color
lightness: word;
Lightness of the color. 0 is black, 32768 is normal, and 65535 is white
alpha: word;
Opacity of the pixel. 0 is transparent and 65535 is opaque
function HSLA(hue, saturation, lightness, alpha: word): THSLAPixel; overload; inline;
Creates a pixel with given HSLA values, where A stands for alpha
function HSLA(hue, saturation, lightness: word): THSLAPixel; overload; inline;
Creates an opaque pixel with given HSL values
function BGRAToHSLA(c: TBGRAPixel): THSLAPixel;
Converts a pixel from sRGB to HSL color space
function ExpandedToHSLA(const ec: TExpandedPixel): THSLAPixel;
Converts a pixel from gamma expanded RGB to HSL color space
function HSLAToExpanded(const c: THSLAPixel): TExpandedPixel;
Converts a pixel from HSL colorspace to gamma expanded RGB
function HSLAToBGRA(const c: THSLAPixel): TBGRAPixel;
Converts a pixel from HSL colorspace to sRGB
function HueDiff(h1, h2: word): word;
Computes the hue difference
function GetHue(ec: TExpandedPixel): word;
Returns the hue of a gamma expanded pixel
TGSBAPixel = THSLAPixel;
Pixel color defined in corrected HSL colorspace. G stands for corrected hue and B stands for actual brightness. Values range from 0 to 65535
function BGRAToGSBA(c: TBGRAPixel): TGSBAPixel;
Converts a pixel from sRGB to correct HSL color space
function ExpandedToGSBA(ec: TExpandedPixel): TGSBAPixel;
Converts a pixel from gamma expanded RGB to correct HSL color space
function GtoH(ghue: word): word;
Converts a G hue (GSBA) to a H hue (HSLA)
function HtoG(hue: word): word;
Converts a H hue (HSLA) to a G hue (GSBA)
function GSBAToBGRA(c: TGSBAPixel): TBGRAPixel;
Converts a pixel from corrected HSL to sRGB
function GSBAToExpanded(c: TGSBAPixel): TExpandedPixel;
Converts a pixel from correct HSL to gamma expanded RGB
function GSBAToHSLA(c: TGSBAPixel): THSLAPixel;
Converts a pixel from correct HSL to usual HSL
TColorF = packed array[1..4] of single;
General purpose color variable with single-precision floating point values
function ColorF(red,green,blue,alpha: single): TColorF;
Creates a TColorF structure
operator - (const c1, c2: TColorF): TColorF; inline;
Subtract each component separately
operator + (const c1, c2: TColorF): TColorF; inline;
Add each component separately
operator * (const c1, c2: TColorF): TColorF; inline;
Multiply each component separately
operator * (const c1: TColorF; factor: single): TColorF; inline;
Multiply each component by factor
TDrawMode = (
Possible modes when drawing a pixel over another one
dmSet,
The pixel is replaced
dmSetExceptTransparent,
The pixel is replaced if the pixel over has an alpha value of 255
dmLinearBlend,
The pixel is blend over the other one according to alpha values, however no gamma correction is applied. In other words, the color space is assumed to be linear
dmDrawWithTransparency,
The pixel is blend over the other one according to alpha values, and a gamma correction is applied. In other word, the color space is assumed to be sRGB
dmXor);
Values of all channels are combined with Xor. This is useful to compute the binary difference, however it is not something that makes much sense to display on the screen
dmFastBlend = dmLinearBlend;
An alias for the linear blend, because it is faster than blending with gamma correction
TBlendOperation = (
Advanced blending modes. See Paint.NET blend modes and Formulas. Blending layers has two steps. The first one is to apply the blend operations listed below, and the second is the actual merging of the colors
boLinearBlend,
Simple blend, except that it forces a linear merge so it is equivalent to dmLinearBlend
boTransparent,
Simple blend. It is equivalent to dmLinearBlend or dmDrawWithTransparency
boLighten, boScreen, boAdditive, boLinearAdd, boColorDodge, boDivide, boNiceGlow, boSoftLight, boHardLight,
Lighting blend modes (tends to increase the luminosity)
boGlow, boReflect, boOverlay, boDarkOverlay, boDarken, boMultiply, boColorBurn,
Masking blend modes (tends to decrease the luminosity)
boDifference, boLinearDifference, boExclusion, boLinearExclusion, boSubtract, boLinearSubtract, boSubtractInverse, boLinearSubtractInverse,
Difference blend modes
boNegation, boLinearNegation,
Negation blend modes
boXor);
Xor blend mode. It is sightly different from dmXor because the alpha value is used like in other blends modes
boGlowMask = boGlow;
Alias to glow that express that this blend mode masks the part where the top layer is black
boLinearMultiply = boMultiply;
Alias because linear or non linear multiply modes are identical
boNonLinearOverlay = boDarkOverlay;
Alias to express that dark overlay is simply an overlay with gamma correction
BlendOperationStr : array[TBlendOperation] of string
String constants for blend modes
function StrToBlendOperation(str: string): TBlendOperation;
Returns the blend mode expressed by the string
TChannel = (cRed, cGreen, cBlue, cAlpha);
Possible channels in a bitmap using any RGBA colorspace
TChannels = set of TChannel;
Combination of channels
TAlphaChannelPaletteOption = (
Specifies how a palette handles the alpha channel
acIgnore,
The alpha channel is ignored. The alpha channel is considered to be stored elsewhere
acTransparentEntry,
One entry is allocated the fully transparent color
acFullChannelInPalette);
The alpha channel is fully embedded in the palette so that a color is identified by its four RGBA channels
TDitheringAlgorithm = (
Dithering algorithms that specifies how to handle colors that are not found in the palette
daNearestNeighbor,
The nearest color is to be used instead
daFloydSteinberg);
The nearest color may be used however another color may be used to compensate for the error, following Floyd-Steinberg algorithm