]> git.sur5r.net Git - cc65/blobdiff - src/sp65/bitmap.c
Merge branch 'master' into master
[cc65] / src / sp65 / bitmap.c
index b00a01651b65c7aa022814923613d5ebaa21536f..4536fb819b1c3770780064eebf2e9904abf82919 100644 (file)
@@ -64,7 +64,6 @@ Bitmap* NewBitmap (unsigned Width, unsigned Height)
     B = xmalloc (sizeof (*B) + (Size - 1) * sizeof (B->Data[0]));
 
     /* Initialize the data */
-    B->Type     = bmUnknown;
     B->Name     = EmptyStrBuf;
     B->Width    = Width;
     B->Height   = Height;
@@ -105,9 +104,9 @@ int ValidBitmapSize (unsigned Width, unsigned Height)
 Bitmap* SliceBitmap (const Bitmap* O, unsigned OrigX, unsigned OrigY,
                      unsigned Width, unsigned Height)
 /* Create a slice of the given bitmap. The slice starts at position X/Y of
- * the original and has the given width and height. Location 0/0 is at the
- * upper left corner.
- */
+** the original and has the given width and height. Location 0/0 is at the
+** upper left corner.
+*/
 {
     Bitmap*  B;
     unsigned Y;
@@ -120,7 +119,6 @@ Bitmap* SliceBitmap (const Bitmap* O, unsigned OrigX, unsigned OrigY,
     B = NewBitmap (Width, Height);
 
     /* Copy fields from the original */
-    B->Type = O->Type;
     if (SB_GetLen (&O->Name) > 0) {
         SB_CopyStr (&B->Name, "Slice of ");
         SB_Append (&B->Name, &O->Name);
@@ -142,15 +140,15 @@ Bitmap* SliceBitmap (const Bitmap* O, unsigned OrigX, unsigned OrigY,
 
 Color GetPixelColor (const Bitmap* B, unsigned X, unsigned Y)
 /* Get the color for a given pixel. For indexed bitmaps, the palette entry
- * is returned.
- */
+** is returned.
+*/
 {
     /* Get the pixel at the given coordinates */
     Pixel P = GetPixel (B, X, Y);
 
     /* If the bitmap has a palette, return the color from the palette. For
-     * simplicity, we will only check the palette, not the type.
-     */
+    ** simplicity, we will only check the palette, not the type.
+    */
     if (B->Pal) {
         if (P.Index >= B->Pal->Count) {
             /* Palette index is invalid */
@@ -168,8 +166,8 @@ Color GetPixelColor (const Bitmap* B, unsigned X, unsigned Y)
 
 Pixel GetPixel (const Bitmap* B, unsigned X, unsigned Y)
 /* Return a pixel from the bitmap. The returned value may either be a color
- * or a palette index, depending on the type of the bitmap.
- */
+** or a palette index, depending on the type of the bitmap.
+*/
 {
     /* Check the coordinates */
     PRECONDITION (X < B->Width && Y < B->Height);
@@ -177,24 +175,3 @@ Pixel GetPixel (const Bitmap* B, unsigned X, unsigned Y)
     /* Return the pixel */
     return B->Data[Y * B->Width + X];
 }
-
-
-
-unsigned GetBitmapColors (const Bitmap* B)
-/* Get the number of colors in an image. The function will return the number
- * of palette entries for indexed bitmaps and 2^24 for non indexed bitmaps.
- */
-{
-    switch (B->Type) {
-        case bmMonochrome:      return 2;
-        case bmIndexed:         return B->Pal->Count;
-        case bmRGB:
-        case bmRGBA:            return (1U << 24);
-        default:                Internal ("Unknown bitmap type %u", B->Type);
-    }
-    /* NOTREACHED */
-    return 0;
-}
-
-
-