mirror of
				https://github.com/vdr-projects/vdr.git
				synced 2025-03-01 10:50:46 +00:00 
			
		
		
		
	Ignoring unused "none" color entries in XPM files written by some broken graphics tools
This commit is contained in:
		@@ -716,6 +716,8 @@ Sascha Volkenandt <sascha@akv-soft.de>
 | 
				
			|||||||
 for reporting a bug in cBitmap::DrawPixel(), which messed with other bitmaps'
 | 
					 for reporting a bug in cBitmap::DrawPixel(), which messed with other bitmaps'
 | 
				
			||||||
 palettes in case the pixel coordinates were outside this bitmap
 | 
					 palettes in case the pixel coordinates were outside this bitmap
 | 
				
			||||||
 for suggesting to allow drawing "transparent" texts
 | 
					 for suggesting to allow drawing "transparent" texts
 | 
				
			||||||
 | 
					 for suggesting to ignore unused "none" color entries in XPM files written by
 | 
				
			||||||
 | 
					 some broken graphics tools
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Malcolm Caldwell <malcolm.caldwell@ntu.edu.au>
 | 
					Malcolm Caldwell <malcolm.caldwell@ntu.edu.au>
 | 
				
			||||||
 for modifying LOF handling to allow for C-band reception
 | 
					 for modifying LOF handling to allow for C-band reception
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								HISTORY
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								HISTORY
									
									
									
									
									
								
							@@ -2879,3 +2879,5 @@ Video Disk Recorder Revision History
 | 
				
			|||||||
- The cBitmap::DrawText() function now doesn't set any background pixels if the
 | 
					- The cBitmap::DrawText() function now doesn't set any background pixels if the
 | 
				
			||||||
  given background color is clrTransparent. This allows drawing "transparent"
 | 
					  given background color is clrTransparent. This allows drawing "transparent"
 | 
				
			||||||
  texts (suggested by Sascha Volkenandt).
 | 
					  texts (suggested by Sascha Volkenandt).
 | 
				
			||||||
 | 
					- The cBitmap::SetXpm() function now ignores unused "none" color entries, which
 | 
				
			||||||
 | 
					  some broken graphics tools write into XPM files (suggested by Sascha Volkenandt).
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										21
									
								
								osd.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								osd.c
									
									
									
									
									
								
							@@ -4,7 +4,7 @@
 | 
				
			|||||||
 * See the main source file 'vdr.c' for copyright information and
 | 
					 * See the main source file 'vdr.c' for copyright information and
 | 
				
			||||||
 * how to reach the author.
 | 
					 * how to reach the author.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * $Id: osd.c 1.50 2004/06/05 11:37:42 kls Exp $
 | 
					 * $Id: osd.c 1.51 2004/06/05 13:20:19 kls Exp $
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "osd.h"
 | 
					#include "osd.h"
 | 
				
			||||||
@@ -244,7 +244,7 @@ bool cBitmap::LoadXpm(const char *FileName)
 | 
				
			|||||||
  return Result;
 | 
					  return Result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool cBitmap::SetXpm(char *Xpm[])
 | 
					bool cBitmap::SetXpm(char *Xpm[], bool IgnoreNone)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  char **p = Xpm;
 | 
					  char **p = Xpm;
 | 
				
			||||||
  int w, h, n, c;
 | 
					  int w, h, n, c;
 | 
				
			||||||
@@ -257,10 +257,11 @@ bool cBitmap::SetXpm(char *Xpm[])
 | 
				
			|||||||
     return false;
 | 
					     return false;
 | 
				
			||||||
     }
 | 
					     }
 | 
				
			||||||
  int b = 0;
 | 
					  int b = 0;
 | 
				
			||||||
  while (1 << (1 << b) < n)
 | 
					  while (1 << (1 << b) < (IgnoreNone ? n - 1 : n))
 | 
				
			||||||
        b++;
 | 
					        b++;
 | 
				
			||||||
  SetBpp(1 << b);
 | 
					  SetBpp(1 << b);
 | 
				
			||||||
  SetSize(w, h);
 | 
					  SetSize(w, h);
 | 
				
			||||||
 | 
					  int NoneColorIndex = MAXNUMCOLORS;
 | 
				
			||||||
  for (int i = 0; i < n; i++) {
 | 
					  for (int i = 0; i < n; i++) {
 | 
				
			||||||
      const char *s = *++p;
 | 
					      const char *s = *++p;
 | 
				
			||||||
      if (int(strlen(s)) < c) {
 | 
					      if (int(strlen(s)) < c) {
 | 
				
			||||||
@@ -273,14 +274,18 @@ bool cBitmap::SetXpm(char *Xpm[])
 | 
				
			|||||||
         return false;
 | 
					         return false;
 | 
				
			||||||
         }
 | 
					         }
 | 
				
			||||||
      s = skipspace(s + 1);
 | 
					      s = skipspace(s + 1);
 | 
				
			||||||
      if (strcasecmp(s, "none") == 0)
 | 
					      if (strcasecmp(s, "none") == 0) {
 | 
				
			||||||
         s = "#00000000";
 | 
					         s = "#00000000";
 | 
				
			||||||
 | 
					         NoneColorIndex = i;
 | 
				
			||||||
 | 
					         if (IgnoreNone)
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					         }
 | 
				
			||||||
      if (*s != '#') {
 | 
					      if (*s != '#') {
 | 
				
			||||||
         esyslog("ERROR: unknown color code in XPM: '%c'", *s);
 | 
					         esyslog("ERROR: unknown color code in XPM: '%c'", *s);
 | 
				
			||||||
         return false;
 | 
					         return false;
 | 
				
			||||||
         }
 | 
					         }
 | 
				
			||||||
      tColor color = strtoul(++s, NULL, 16) | 0xFF000000;
 | 
					      tColor color = strtoul(++s, NULL, 16) | 0xFF000000;
 | 
				
			||||||
      SetColor(i, color);
 | 
					      SetColor((IgnoreNone && i > NoneColorIndex) ? i - 1 : i, color);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
  for (int y = 0; y < h; y++) {
 | 
					  for (int y = 0; y < h; y++) {
 | 
				
			||||||
      const char *s = *++p;
 | 
					      const char *s = *++p;
 | 
				
			||||||
@@ -295,13 +300,17 @@ bool cBitmap::SetXpm(char *Xpm[])
 | 
				
			|||||||
                 return false;
 | 
					                 return false;
 | 
				
			||||||
                 }
 | 
					                 }
 | 
				
			||||||
              if (strncmp(Xpm[i + 1], s, c) == 0) {
 | 
					              if (strncmp(Xpm[i + 1], s, c) == 0) {
 | 
				
			||||||
                 SetIndex(x, y, i);
 | 
					                 if (i == NoneColorIndex)
 | 
				
			||||||
 | 
					                    NoneColorIndex = MAXNUMCOLORS;
 | 
				
			||||||
 | 
					                 SetIndex(x, y, (IgnoreNone && i > NoneColorIndex) ? i - 1 : i);
 | 
				
			||||||
                 break;
 | 
					                 break;
 | 
				
			||||||
                 }
 | 
					                 }
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
          s += c;
 | 
					          s += c;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					  if (NoneColorIndex < MAXNUMCOLORS && !IgnoreNone)
 | 
				
			||||||
 | 
					     return SetXpm(Xpm, true);
 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										10
									
								
								osd.h
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								osd.h
									
									
									
									
									
								
							@@ -4,7 +4,7 @@
 | 
				
			|||||||
 * See the main source file 'vdr.c' for copyright information and
 | 
					 * See the main source file 'vdr.c' for copyright information and
 | 
				
			||||||
 * how to reach the author.
 | 
					 * how to reach the author.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * $Id: osd.h 1.44 2004/06/05 11:40:12 kls Exp $
 | 
					 * $Id: osd.h 1.45 2004/06/05 12:38:44 kls Exp $
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef __OSD_H
 | 
					#ifndef __OSD_H
 | 
				
			||||||
@@ -136,9 +136,15 @@ public:
 | 
				
			|||||||
  bool LoadXpm(const char *FileName);
 | 
					  bool LoadXpm(const char *FileName);
 | 
				
			||||||
       ///< Calls SetXpm() with the data from the file FileName.
 | 
					       ///< Calls SetXpm() with the data from the file FileName.
 | 
				
			||||||
       ///< Returns true if the operation was successful.
 | 
					       ///< Returns true if the operation was successful.
 | 
				
			||||||
  bool SetXpm(char *Xpm[]);
 | 
					  bool SetXpm(char *Xpm[], bool IgnoreNone = false);
 | 
				
			||||||
       ///< Sets this bitmap to the given XPM data. Any previous bitmap or
 | 
					       ///< Sets this bitmap to the given XPM data. Any previous bitmap or
 | 
				
			||||||
       ///< palette data will be overwritten with the new data.
 | 
					       ///< palette data will be overwritten with the new data.
 | 
				
			||||||
 | 
					       ///< If IgnoreNone is true, a "none" color entry will be ignored.
 | 
				
			||||||
 | 
					       ///< Only set IgnoreNone to true if you know that there is a "none"
 | 
				
			||||||
 | 
					       ///< color entry in the XPM data and that this entry is not used!
 | 
				
			||||||
 | 
					       ///< If SetXpm() is called with IgnoreNone set to false and the XPM
 | 
				
			||||||
 | 
					       ///< data contains an unused "none" entry, it will be automatically
 | 
				
			||||||
 | 
					       ///< called again with IgnoreNone set to true.
 | 
				
			||||||
       ///< Returns true if the operation was successful.
 | 
					       ///< Returns true if the operation was successful.
 | 
				
			||||||
  void SetIndex(int x, int y, tIndex Index);
 | 
					  void SetIndex(int x, int y, tIndex Index);
 | 
				
			||||||
       ///< Sets the index at the given coordinates to Index.
 | 
					       ///< Sets the index at the given coordinates to Index.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user