mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 03:40:05 +00:00 
			
		
		
		
	Update level 3 color tables for 16-level products
This commit is contained in:
		
							parent
							
								
									2dcd87700c
								
							
						
					
					
						commit
						304297be9b
					
				
					 2 changed files with 38 additions and 27 deletions
				
			
		|  | @ -152,23 +152,26 @@ void Level3ProductView::UpdateColorTable() | ||||||
|    float    scale     = descriptionBlock->scale(); |    float    scale     = descriptionBlock->scale(); | ||||||
|    uint16_t threshold = descriptionBlock->threshold(); |    uint16_t threshold = descriptionBlock->threshold(); | ||||||
| 
 | 
 | ||||||
|  |    // If the threshold is 2, the range min should be set to 1 for range folding
 | ||||||
|  |    uint16_t rangeMin       = std::min<uint16_t>(1, threshold); | ||||||
|  |    uint16_t numberOfLevels = descriptionBlock->number_of_levels(); | ||||||
|  |    uint16_t rangeMax       = (numberOfLevels > 0) ? numberOfLevels - 1 : 0; | ||||||
|  | 
 | ||||||
|    if (p->savedColorTable_ == p->colorTable_ && //
 |    if (p->savedColorTable_ == p->colorTable_ && //
 | ||||||
|        p->savedOffset_ == offset &&             //
 |        p->savedOffset_ == offset &&             //
 | ||||||
|        p->savedScale_ == scale) |        p->savedScale_ == scale &&               //
 | ||||||
|  |        numberOfLevels > 16) | ||||||
|    { |    { | ||||||
|       // The color table LUT does not need updated
 |       // The color table LUT does not need updated
 | ||||||
|       return; |       return; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    // If the threshold is 2, the range min should be set to 1 for range folding
 |    // Iterate over [rangeMin, numberOfLevels)
 | ||||||
|    uint16_t rangeMin = std::min<uint16_t>(1, threshold); |  | ||||||
|    uint16_t rangeMax = descriptionBlock->number_of_levels(); |  | ||||||
| 
 |  | ||||||
|    boost::integer_range<uint16_t> dataRange = |    boost::integer_range<uint16_t> dataRange = | ||||||
|       boost::irange<uint16_t>(rangeMin, rangeMax + 1); |       boost::irange<uint16_t>(rangeMin, numberOfLevels); | ||||||
| 
 | 
 | ||||||
|    std::vector<boost::gil::rgba8_pixel_t>& lut = p->colorTableLut_; |    std::vector<boost::gil::rgba8_pixel_t>& lut = p->colorTableLut_; | ||||||
|    lut.resize(rangeMax - rangeMin + 1); |    lut.resize(numberOfLevels - rangeMin); | ||||||
|    lut.shrink_to_fit(); |    lut.shrink_to_fit(); | ||||||
| 
 | 
 | ||||||
|    std::for_each(std::execution::par_unseq, |    std::for_each(std::execution::par_unseq, | ||||||
|  | @ -184,7 +187,10 @@ void Level3ProductView::UpdateColorTable() | ||||||
|                     { |                     { | ||||||
|                        float f; |                        float f; | ||||||
| 
 | 
 | ||||||
|                        // Different products use different scale/offset formulas
 |                        // Different products use different scale/offset
 | ||||||
|  |                        // formulas
 | ||||||
|  |                        if (numberOfLevels > 16) | ||||||
|  |                        { | ||||||
|                           switch (descriptionBlock->product_code()) |                           switch (descriptionBlock->product_code()) | ||||||
|                           { |                           { | ||||||
|                           case 159: |                           case 159: | ||||||
|  | @ -205,6 +211,11 @@ void Level3ProductView::UpdateColorTable() | ||||||
|                              f = i * scale + offset; |                              f = i * scale + offset; | ||||||
|                              break; |                              break; | ||||||
|                           } |                           } | ||||||
|  |                        } | ||||||
|  |                        else | ||||||
|  |                        { | ||||||
|  |                           f = descriptionBlock->data_level_threshold(i); | ||||||
|  |                        } | ||||||
| 
 | 
 | ||||||
|                        lut[i - *dataRange.begin()] = p->colorTable_->Color(f); |                        lut[i - *dataRange.begin()] = p->colorTable_->Color(f); | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|  | @ -528,11 +528,11 @@ uint16_t ProductDescriptionBlock::number_of_levels() const | ||||||
|       break; |       break; | ||||||
| 
 | 
 | ||||||
|    case 134: |    case 134: | ||||||
|       numberOfLevels = 254; |       numberOfLevels = 256; | ||||||
|       break; |       break; | ||||||
| 
 | 
 | ||||||
|    case 135: |    case 135: | ||||||
|       numberOfLevels = 199; |       numberOfLevels = 200; | ||||||
|       break; |       break; | ||||||
| 
 | 
 | ||||||
|    case 138: |    case 138: | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat