17#if defined(__BORLANDC__)
75 logPal->palVersion = 0x300;
84 WARNX(
OwlGDI, !
Handle, 0,
"Cannot create palette from palette " <<
static_cast<void*
>(
src.GetHandle()));
100#if defined(OWL5_COMPAT)
133 logPal->palVersion = 0x300;
140 "palette entries @" <<
static_cast<const void*
>(
entries));
156#if defined(OWL5_COMPAT)
216 info->bmiHeader.biClrUsed :
223 logPal->palVersion = 0x300;
229 logPal->palPalEntry[
n].peFlags =
static_cast<uint8>(flags);
237 WARNX(
OwlGDI, !
Handle, 0,
"Cannot create palette from bitmapinfo @" <<
static_cast<const void*
>(
info));
331 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_PAL() Not a RIFF or PAL file");
339 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_PAL() No data chunk in file");
359 if (
pLogPal->palVersion != 0x300) {
360 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_PAL(): Invalid version number");
365 if (
pLogPal->palNumEntries <= 0){
366 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_PAL(): No colors in palette");
385 WARNX(
OwlGDI, 1, 0,
"TPalette::Write_PAL() Failed to create RIFF-PAL chunk");
393 WARNX(
OwlGDI, 1, 0,
"TPalette::Write_PAL() no colors in palette");
399 logPal->palVersion = 0x300;
408 WARNX(
OwlGDI, 1, 0,
"TPalette::Write_PAL() Failed to create data chunk");
413 WARNX(
OwlGDI, 1, 0,
"TPalette::Write_PAL() Failed to write data chunk");
430 v = (
l <= 0.5) ? (
l * (1.0 +
sl)) : (
l +
sl -
l *
sl);
448 case 0: *
r =
v; *
g =
mid1; *
b =
m;
break;
449 case 1: *
r =
mid2; *
g =
v; *
b =
m;
break;
450 case 2: *
r =
m; *
g =
v; *
b =
mid1;
break;
451 case 3: *
r =
m; *
g =
mid2; *
b =
v;
break;
452 case 4: *
r =
mid1; *
g =
m; *
b =
v;
break;
453 case 5: *
r =
v; *
g =
m; *
b =
mid2;
break;
463static TBinField ACO_HdrFields[] = {
476static TBinField ACO_ColorFields[] = {
492#define CMYK(c,m,y,k) (static_cast<COLORREF>((((BYTE)(c)|((WORD)((BYTE)(m))<<8))|(((DWORD)(BYTE)(y))<<16))|(((DWORD)(BYTE)(k))<<24)))
494#define GetCValue(cmyk) ((BYTE)(cmyk))
495#define GetMValue(cmyk) ((BYTE)((cmyk)>> 8))
496#define GetYValue(cmyk) ((BYTE)((cmyk)>>16))
497#define GetKValue(cmyk) ((BYTE)((cmyk)>>24))
510 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_ACO() Failed to read ACO header");
513 TRACEX(
OwlGDI, 1,
"TPalette::Read_ACO() Data for header: hdr.Version = " <<
dec <<
hdr.Version <<
", hdr.Count = " <<
hdr.Count);
514 if(
hdr.Version != 1){
515 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_ACO() Invalid version number");
523 for(
int i = 0;
i <
hdr.Count;
i++){
530 TRACEX(
OwlGDI, 1,
"TPalette::Read_ACO() Data for Colors:");
531 for (
int j= 0;
j <
hdr.Count;
j++){
532 TRACEX(
OwlGDI, 1,
"TPalette::Read_ACO() index("<<
dec <<
j <<
"), clrSpace("
533 <<
clr[
j].clrSpace <<
"), Color1("<<
clr[
j].Color1<<
"), Color2(" <<
534 clr[
j].Color2<<
"), Color3("<<
clr[
j].Color3<<
"), Color4("<<
535 clr[
j].Color4<<
")");
539 LogPal.palVersion = 0x300;
540 LogPal.palNumEntries = 256;
551 for (
int k= 0;
k <
hdr.Count;
k++){
552 switch(
clr[
k].clrSpace){
560 LogPal.palPalEntry[
k].peFlags = 0;
566 h =
clr[
k].Color1/65535.0;
567 s =
clr[
k].Color2/65535.0;
568 l =
clr[
k].Color3/65535.0;
574 LogPal.palPalEntry[
k].peFlags = 0;
588 LogPal.palPalEntry[
k].peFlags = 0;
605 LogPal.palPalEntry[
k].peFlags = 0;
611 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_ACO() Error no colors found.");
629 WARNX(
OwlGDI, 1, 0,
"TPalette::Write_ACO() Error no colors in palette");
642 WARNX(
OwlGDI, 1, 0,
"TPalette::Write_ACO() Failed to write ACO header");
677 LogPal.palVersion = 0x300;
678 LogPal.palNumEntries = 256;
685 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_ACT() Failed to read ACT colors");
688 for (
int i= 0;
i < 256;
i++){
692 LogPal.palPalEntry[
i].peFlags = 0;
707 WARNX(
OwlGDI, 1, 0,
"TPalette::Write_ACT() Error no colors in palette");
720 for (;
i < 256;
i++){
727 if(!
file.Write(
reinterpret_cast<char*
>(&
clr),
sizeof(
clr))) {
728 WARNX(
OwlGDI, 1, 0,
"TPalette::Write_ACT() Failed to write ACT data");
743 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_BMP() Failed to read BMP header");
748 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_BMP() Not a Windows 3.x or PM 1.x bitmap file");
759 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_BMP() Not a Windows 3.x or PM 1.x bitmap file");
773 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_BMP() Invalid PM 1.x DIB Header");
787 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_BMP() Invalid Win 3.x DIB Header");
797 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_BMP() Invalid number of planes in DIB");
816 WARNX(
OwlGDI, 1, 0,
"TPalette::Read_BMP() Could not read DIB color table");
821 Colors[
i].rgbRed = ((
RGBTRIPLE*)Colors)[
i].rgbtRed;
822 Colors[
i].rgbGreen = ((
RGBTRIPLE*)Colors)[
i].rgbtGreen;
823 Colors[
i].rgbBlue = ((
RGBTRIPLE*)Colors)[
i].rgbtBlue;
828 LogPal.palVersion = 0x300;
829 LogPal.palNumEntries = 256;
833 LogPal.palPalEntry[
i].peRed = Colors[
i].rgbRed;
834 LogPal.palPalEntry[
i].peGreen = Colors[
i].rgbGreen;
835 LogPal.palPalEntry[
i].peBlue = Colors[
i].rgbBlue;
836 LogPal.palPalEntry[
i].peFlags = 0;
839 LogPal.palPalEntry[
i].peRed = 0;
840 LogPal.palPalEntry[
i].peGreen = 0;
841 LogPal.palPalEntry[
i].peBlue = 0;
842 LogPal.palPalEntry[
i].peFlags = 0;
860 WARNX(
OwlGDI, 1, 0,
"TPalette::Write_BMP() Error write header");
879 WARNX(
OwlGDI, 1, 0,
"TPalette::Write_BMP() Failed to write BMP Info header");
886 WARNX(
OwlGDI, 1, 0,
"TPalette::Write_BMP() no colors in palette");
898 clr[
i].rgbReserved = 0;
900 for (;
i < 256;
i++){
904 clr[
i].rgbReserved = 0;
909 WARNX(
OwlGDI, 1, 0,
"TPalette::Write_BMP() Failed to write BMP Colors");
915 WARNX(
OwlGDI, 1, 0,
"TPalette::Write_BMP() Failed to write BMP 1x1 bitmap");
#define WARNX(group, condition, level, message)
#define PRECONDITION(condition)
#define DIAG_DECLARE_GROUP(group)
#define TRACEX(group, level, message)
The clipboard class encapsulates the methods for the clipboard object of Windows.
HANDLE SetClipboardData(uint format, HANDLE handle)
Copy the data onto the clipboard in the format.
Pseudo-GDI object Device Independent Bitmap (DIB) class.
@ CreateAlways
Creates a new file. The function overwrites the file if it exists.
The TFileName class constructs filenames.
bool Remove() const
Deletes this file associated with this name if possible; otherwise attempts to delete the directory a...
GdiObject is the root, pseudo-abstract base class for ObjectWindows' GDI (Graphics Device Interface) ...
static void RefInc(HANDLE handle)
Increments by 1 the reference count of the object associated with the given handle.
void CheckValid(uint resId=IDS_GDIFAILURE)
static void RefRemove(HANDLE handle)
Removes the reference entry to the object with the given handle.
bool ShouldDelete
Should object delete GDI handle in dtor?
static void RefAdd(HANDLE handle, TType type)
RefAdd adds a reference entry for the object with the given handle and type.
HANDLE Handle
GDI handle of this object.
TPalette is the GDI Palette class derived from TGdiObject.
TPalette(HPALETTE handle, TAutoDelete autoDelete=NoAutoDelete)
Alias an existing palette handle. Assume ownership if autoDelete says so.
bool Write_BMP(TRiffFile &file)
Write palette to BMP 1x1 file.
bool Read_BMP(TRiffFile &file)
Read palette from BMP file.
uint GetPaletteEntries(uint16 start, uint16 count, PALETTEENTRY *entries) const
Retrieves a range of entries in this logical palette and places them in the entries array.
bool Write_PAL(TRiffFile &file)
Write Microsoft palette to file.
bool GetObject(uint16 &numEntries) const
Finds the number of entries in this logical palette and sets the value in the numEntries argument.
bool Write(const tchar *fileName)
Write this palette into file: *.dib,*.bmp,*.pal,*.aco,*.act.
bool Read_ACO(TRiffFile &file)
Read Adobe palette from file.
void Create(const BITMAPINFO *info, uint flags)
Accept a pointer to a BITMAPINFO structure and create a GDI logical palette from the color table whic...
bool Read_PAL(TRiffFile &file)
Read Microsoft palette from file.
void ToClipboard(TClipboard &Clipboard)
Moves this palette to the target Clipboard argument.
bool Write_ACT(TRiffFile &file)
Write Adobe palette to file.
bool Read(const tchar *fileName)
Read palette from file.
bool Write_ACO(TRiffFile &file)
Write Adobe palette to file.
bool Read_ACT(TRiffFile &file)
Read Adobe palette from file.
The TRiffFile class is used for reading and writing RIFF files.
Definition of classes for clipboard Encapsulation.
Definition of abstract GDI object class and derived classes.
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
#define owlFCC(ch0, ch1, ch2, ch3)
@ boLittle_Endian
LSB at lowest address: Intel //.
@ boBig_Endian
MSB at lowest address: Motorola //.
Reliable platform independent header for common memory and string functions.
Object Windows Library (OWLNext Core)
long NColors(uint16 bitCount)
Functions to convert number of bits to number of palette colors and back, and build an RGB COLORREF.
void HSL_to_RGB(double &h, double &sl, double &l, double *r, double *g, double *b)
convert HSL to RGB
General definitions used by all ObjectWindows programs.
The TBinField struct describes a group of like-typed fields in a structure to be read or written usin...
RIFF chunk information data structure.