b8180d9f6d41dc708a2f249ba892cbca311e7a06
jcasper
  Mon Feb 27 11:38:55 2023 -0800
Adding transparency support for colors refs #30569

diff --git src/inc/basicBed.h src/inc/basicBed.h
index d9e3a9a..7ca8d8f 100644
--- src/inc/basicBed.h
+++ src/inc/basicBed.h
@@ -1,29 +1,30 @@
 /* basicBed.h contains the basic interface to Browser Extensible Data (bed) files and tables.
  * The idea behind bed is that the first three fields are defined and required.
  * A total of 15 fields are defined, and the file can contain any number of these.
  * In addition after any number of defined fields there can be custom fields that
  * are not defined in the bed spec.
  *
  * There's additional bed-related code in src/hg/inc/bed.h.  This module contains the
  * stuff that's independent of the database and other genomic structures. */
 
 #ifndef BASICBED_H
 #define BASICBED_H
 
 #include "psl.h"
 #include "asParse.h"
+#include "memgfx.h"
 
 struct bed
 /* Browser extensible data */
     {
     struct bed *next;  /* Next in singly linked list. */
     char *chrom;	/* Human chromosome or FPC contig */
     unsigned chromStart;	/* Start position in chromosome */
     unsigned chromEnd;	/* End position in chromosome */
     char *name;	/* Name of item */
 
     /* The following items are not loaded by   the bedLoad routines. */
     int score; /* Score - 0-1000 */  /* Should be uint but there are still some ct users with neg values, .as DOES say uint */
     char strand[2];  /* + or -.  */
     unsigned thickStart; /* Start of where display should be thick (start codon for genes) */
     unsigned thickEnd;   /* End of where display should be thick (stop codon for genes) */
@@ -254,39 +255,52 @@
 /* Return next bed in list that is from a different chrom than the start of the list. */
 
 struct bed *lmCloneBed(struct bed *bed, struct lm *lm);
 /* Make a copy of bed in local memory. */
 
 struct bed *bedCommaInN(char **pS, struct bed *ret, int fieldCount);
 /* Create a bed out of a comma separated string looking for fieldCount
  * fields. This will fill in ret if non-null, otherwise will return a
  * new bed */
 
 struct hash *readBedToBinKeeper(char *sizeFileName, char *bedFileName, int wordCount);
 /* Read a list of beds and return results in hash of binKeeper structure for fast query
  * See also bedsIntoKeeperHash, which takes the beds read into a list already, but
  * dispenses with the need for the sizeFile. */
 
-int bedParseRgb(char *itemRgb);
-/*	parse a string: "r,g,b" into three unsigned char values
-	returned as 24 bit number, or -1 for failure */
+unsigned int bedParseRgb(char *itemRgb);
+/*      parse a string: "r,g,b" with optional ",a" into three or four unsigned
+ *      char values returned as 32 bit number, or -1 for failure.  Byte order
+ *      has alpha in the highest-order byte, then r, then g, then b in the
+ *      lowest-order byte. This is a "bed" concept of an unsigned color,
+ *      which may not match the way the graphics libraries handle color bytes. */
 
-int bedParseColor(char *colorSpec);
-/* Parse an HTML color string, a  string of 3 comma-sep unsigned color values 0-255, 
+unsigned int bedParseColor(char *colorSpec);
+/* Parse an HTML color string, a  string of 3 or 4 comma-sep unsigned color values 0-255, 
  * or a 6-digit hex string  preceded by #. 
  * O/w return unsigned integer value.  Return -1 on error */
 
+struct rgbColor bedColorToRgb(unsigned int color);
+/* Convert from the bed concept of a color uint, where the rgb bits
+ * are always in the same order, to a memgfx color structure. */
+
+Color bedColorToGfxColor(unsigned int color);
+/* Convert from the bed concept of a color uint, where the rgb bits
+ * are always in the same order, to a memgfx concept of color where
+ * the bit order depends on architecture. Assumes that a bed color
+ * will never have 0 alpha. */
+
 void bedOutputRgb(FILE *f, unsigned int color);
 /*      Output a string: "r,g,b" for 24 bit number */
 
 long long bedTotalSize(struct bed *bedList);
 /* Add together sizes of all beds in list. */
 
 int bedSameStrandOverlap(struct bed *a, struct bed *b);
 /* Return amount of block-level overlap on same strand between a and b */
 
 boolean bedExactMatch(struct bed *oldBed, struct bed *newBed);
 /* Return TRUE if it's an exact match. */
 
 boolean bedCompatibleExtension(struct bed *oldBed, struct bed *newBed);
 /* Return TRUE if newBed is a compatible extension of oldBed, meaning
  * all internal exons and all introns of old bed are contained, in the