Skip to content

Commit 54272c9

Browse files
committed
Improved converters
1 parent dba3891 commit 54272c9

1 file changed

Lines changed: 41 additions & 3 deletions

File tree

src/libImaging/Convert.c

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,18 @@ l2cmyk(UINT8* out, const UINT8* in, int xsize)
517517
}
518518
}
519519

520+
static void
521+
la2cmyk(UINT8* out, const UINT8* in, int xsize)
522+
{
523+
int x;
524+
for (x = 0; x < xsize; x++, in += 4) {
525+
*out++ = 0;
526+
*out++ = 0;
527+
*out++ = 0;
528+
*out++ = ~(in[0]);
529+
}
530+
}
531+
520532
static void
521533
rgb2cmyk(UINT8* out, const UINT8* in, int xsize)
522534
{
@@ -673,6 +685,18 @@ l2ycbcr(UINT8* out, const UINT8* in, int xsize)
673685
}
674686
}
675687

688+
static void
689+
la2ycbcr(UINT8* out, const UINT8* in, int xsize)
690+
{
691+
int x;
692+
for (x = 0; x < xsize; x++, in += 4) {
693+
*out++ = in[0];
694+
*out++ = 128;
695+
*out++ = 128;
696+
*out++ = 255;
697+
}
698+
}
699+
676700
static void
677701
ycbcr2l(UINT8* out, const UINT8* in, int xsize)
678702
{
@@ -681,6 +705,16 @@ ycbcr2l(UINT8* out, const UINT8* in, int xsize)
681705
*out++ = in[0];
682706
}
683707

708+
static void
709+
ycbcr2la(UINT8* out, const UINT8* in, int xsize)
710+
{
711+
int x;
712+
for (x = 0; x < xsize; x++, in += 4, out += 4) {
713+
out[0] = out[1] = out[2] = in[0];
714+
out[3] = 255;
715+
}
716+
}
717+
684718
/* ------------------------- */
685719
/* I;16 (16-bit) conversions */
686720
/* ------------------------- */
@@ -818,8 +852,10 @@ static struct {
818852
{ "LA", "L", la2l },
819853
{ "LA", "La", lA2la },
820854
{ "LA", "RGB", la2rgb },
821-
{ "LA", "RGBX", la2rgb },
822855
{ "LA", "RGBA", la2rgb },
856+
{ "LA", "RGBX", la2rgb },
857+
{ "LA", "CMYK", la2cmyk },
858+
{ "LA", "YCbCr", la2ycbcr },
823859

824860
{ "La", "LA", la2lA },
825861

@@ -861,8 +897,9 @@ static struct {
861897

862898
{ "RGBX", "1", rgb2bit },
863899
{ "RGBX", "L", rgb2l },
864-
{ "RGBA", "I", rgb2i },
865-
{ "RGBA", "F", rgb2f },
900+
{ "RGBX", "LA", rgb2la },
901+
{ "RGBX", "I", rgb2i },
902+
{ "RGBX", "F", rgb2f },
866903
{ "RGBX", "RGB", rgba2rgb },
867904
{ "RGBX", "CMYK", rgb2cmyk },
868905
{ "RGBX", "YCbCr", ImagingConvertRGB2YCbCr },
@@ -872,6 +909,7 @@ static struct {
872909
{ "CMYK", "RGBX", cmyk2rgb },
873910

874911
{ "YCbCr", "L", ycbcr2l },
912+
{ "YCbCr", "LA", ycbcr2la },
875913
{ "YCbCr", "RGB", ImagingConvertYCbCr2RGB },
876914

877915
{ "HSV", "RGB", hsv2rgb },

0 commit comments

Comments
 (0)