mirror of
				https://github.com/vdr-projects/vdr.git
				synced 2025-03-01 10:50:46 +00:00 
			
		
		
		
	Fixed handling the bitmap color depth for scaled subtitles
This commit is contained in:
		| @@ -1268,6 +1268,7 @@ Reinhard Nissl <rnissl@gmx.de> | ||||
|  for reporting a problem with horizontal scaling of subtitles | ||||
|  for fixing a buffer overflow in cFont::Bidi() | ||||
|  for avoiding an unecessary call to Recordings.ResetResume() | ||||
|  for debugging a problem in handling the bitmap color depth for scaled subtitles | ||||
|  | ||||
| Richard Robson <richard_robson@beeb.net> | ||||
|  for reporting freezing replay if a timer starts while in Transfer Mode from the | ||||
|   | ||||
							
								
								
									
										4
									
								
								HISTORY
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								HISTORY
									
									
									
									
									
								
							| @@ -6573,8 +6573,8 @@ Video Disk Recorder Revision History | ||||
| - Fixed cUnbufferedFile::Seek() in case it is compiled without USE_FADVISE (thanks | ||||
|   to Juergen Lock). | ||||
| - Fixed the Language header of the Serbian translation file (thanks to Ville Skytt<74>). | ||||
| - Added anti-aliasing when upscaling bitmaps (improves the display of SD subtitles | ||||
|   when replayed on an HD OSD). | ||||
| - Added anti-aliasing when upscaling bitmaps, which improves the display of SD subtitles | ||||
|   when replayed on an HD OSD (thanks to Reinhard Nissl for his help in debugging). | ||||
| - Renamed cBitmap::Scale() to Scaled(), because it doesn't modify the bitmap itself, | ||||
|   but rather returns a scaled copy. | ||||
| - Fixed the description of cReceiver in PLUGINS.html, regarding detaching a receiver | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|  * Original author: Marco Schl<68><6C>ler <marco@lordzodiac.de> | ||||
|  * With some input from the "subtitle plugin" by Pekka Virtanen <pekka.virtanen@sci.fi> | ||||
|  * | ||||
|  * $Id: dvbsubtitle.c 2.16 2011/03/27 15:02:12 kls Exp $ | ||||
|  * $Id: dvbsubtitle.c 2.17 2011/04/17 14:34:05 kls Exp $ | ||||
|  */ | ||||
|  | ||||
|  | ||||
| @@ -655,11 +655,26 @@ void cDvbSubtitleBitmaps::AddBitmap(cBitmap *Bitmap) | ||||
|  | ||||
| void cDvbSubtitleBitmaps::Draw(cOsd *Osd) | ||||
| { | ||||
|   bool Scale = !(DoubleEqual(osdFactorX, 1.0) && DoubleEqual(osdFactorY, 1.0)); | ||||
|   bool AntiAlias = true; | ||||
|   if (Scale && osdFactorX > 1.0 || osdFactorY > 1.0) { | ||||
|      // Upscaling requires 8bpp: | ||||
|      int Bpp[MAXOSDAREAS]; | ||||
|      for (int i = 0; i < numAreas; i++) { | ||||
|          Bpp[i] = areas[i].bpp; | ||||
|          areas[i].bpp = 8; | ||||
|          } | ||||
|      if (Osd->CanHandleAreas(areas, numAreas) != oeOk) { | ||||
|         for (int i = 0; i < numAreas; i++) | ||||
|             Bpp[i] = areas[i].bpp = Bpp[i]; | ||||
|         AntiAlias = false; | ||||
|         } | ||||
|      } | ||||
|   if (Osd->SetAreas(areas, numAreas) == oeOk) { | ||||
|      for (int i = 0; i < bitmaps.Size(); i++) { | ||||
|          cBitmap *b = bitmaps[i]; | ||||
|          if (!(DoubleEqual(osdFactorX, 1.0) && DoubleEqual(osdFactorY, 1.0))) | ||||
|             b = b->Scaled(osdFactorX, osdFactorY); | ||||
|          if (Scale) | ||||
|             b = b->Scaled(osdFactorX, osdFactorY, AntiAlias); | ||||
|          Osd->DrawBitmap(int(round(b->X0() * osdFactorX)), int(round(b->Y0() * osdFactorY)), *b); | ||||
|          if (b != bitmaps[i]) | ||||
|             delete b; | ||||
|   | ||||
							
								
								
									
										6
									
								
								osd.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								osd.c
									
									
									
									
									
								
							| @@ -4,7 +4,7 @@ | ||||
|  * See the main source file 'vdr.c' for copyright information and | ||||
|  * how to reach the author. | ||||
|  * | ||||
|  * $Id: osd.c 2.20 2011/03/27 11:52:12 kls Exp $ | ||||
|  * $Id: osd.c 2.21 2011/04/17 14:25:07 kls Exp $ | ||||
|  */ | ||||
|  | ||||
| #include "osd.h" | ||||
| @@ -806,7 +806,7 @@ void cBitmap::ShrinkBpp(int NewBpp) | ||||
|      } | ||||
| } | ||||
|  | ||||
| cBitmap *cBitmap::Scaled(double FactorX, double FactorY) | ||||
| cBitmap *cBitmap::Scaled(double FactorX, double FactorY, bool AntiAlias) | ||||
| { | ||||
|   // Fixed point scaling code based on www.inversereality.org/files/bitmapscaling.pdf | ||||
|   // by deltener@mindtremors.com | ||||
| @@ -814,7 +814,7 @@ cBitmap *cBitmap::Scaled(double FactorX, double FactorY) | ||||
|   b->Replace(*this); // copy palette | ||||
|   int RatioX = (Width() << 16) / b->Width(); | ||||
|   int RatioY = (Height() << 16) / b->Height(); | ||||
|   if (FactorX <= 1.0 && FactorY <= 1.0) { | ||||
|   if (!AntiAlias || FactorX <= 1.0 && FactorY <= 1.0) { | ||||
|      // Downscaling - no anti-aliasing: | ||||
|      tIndex *DestRow = b->bitmap; | ||||
|      int SourceY = 0; | ||||
|   | ||||
							
								
								
									
										7
									
								
								osd.h
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								osd.h
									
									
									
									
									
								
							| @@ -4,7 +4,7 @@ | ||||
|  * See the main source file 'vdr.c' for copyright information and | ||||
|  * how to reach the author. | ||||
|  * | ||||
|  * $Id: osd.h 2.12 2011/03/27 11:51:48 kls Exp $ | ||||
|  * $Id: osd.h 2.13 2011/04/17 14:24:32 kls Exp $ | ||||
|  */ | ||||
|  | ||||
| #ifndef __OSD_H | ||||
| @@ -273,8 +273,11 @@ public: | ||||
|        ///< the 2^NewBpp most frequently used colors as defined in the current palette. | ||||
|        ///< If NewBpp is not smaller than the bitmap's current color depth, | ||||
|        ///< or if it is not one of 4bpp or 2bpp, nothing happens. | ||||
|   cBitmap *Scaled(double FactorX, double FactorY); | ||||
|   cBitmap *Scaled(double FactorX, double FactorY, bool AntiAlias = false); | ||||
|        ///< Creates a copy of this bitmap, scaled by the given factors. | ||||
|        ///< If AntiAlias is true and either of the factors is greater than 1.0, | ||||
|        ///< anti-aliasing is applied. This will also set the color depth of the | ||||
|        ///< returned bitmap to 8bpp. | ||||
|        ///< The caller must delete the returned bitmap once it is no longer used. | ||||
|   }; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user