mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Corrected drawing I;16 points
This commit is contained in:
		
							parent
							
								
									3ee9259150
								
							
						
					
					
						commit
						5e2332a200
					
				
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 181 B After Width: | Height: | Size: 180 B  | 
| 
						 | 
				
			
			@ -586,6 +586,18 @@ def test_point(points):
 | 
			
		|||
    assert_image_equal_tofile(im, "Tests/images/imagedraw_point.png")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_point_I16():
 | 
			
		||||
    # Arrange
 | 
			
		||||
    im = Image.new("I;16", (1, 1))
 | 
			
		||||
    draw = ImageDraw.Draw(im)
 | 
			
		||||
 | 
			
		||||
    # Act
 | 
			
		||||
    draw.point((0, 0), fill=0x1234)
 | 
			
		||||
 | 
			
		||||
    # Assert
 | 
			
		||||
    assert im.getpixel((0, 0)) == 0x1234
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@pytest.mark.parametrize("points", POINTS)
 | 
			
		||||
def test_polygon(points):
 | 
			
		||||
    # Arrange
 | 
			
		||||
| 
						 | 
				
			
			@ -732,7 +744,7 @@ def test_rectangle_I16(bbox):
 | 
			
		|||
    draw = ImageDraw.Draw(im)
 | 
			
		||||
 | 
			
		||||
    # Act
 | 
			
		||||
    draw.rectangle(bbox, fill="black", outline="green")
 | 
			
		||||
    draw.rectangle(bbox, outline=0xFFFF)
 | 
			
		||||
 | 
			
		||||
    # Assert
 | 
			
		||||
    assert_image_equal_tofile(im.convert("I"), "Tests/images/imagedraw_rectangle_I.png")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,6 +41,7 @@
 | 
			
		|||
#define FLOOR(v) ((v) >= 0.0 ? (int)(v) : (int)floor(v))
 | 
			
		||||
 | 
			
		||||
#define INK8(ink) (*(UINT8 *)ink)
 | 
			
		||||
#define INK16(ink) (*(UINT16 *)ink)
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Rounds around zero (up=away from zero, down=towards zero)
 | 
			
		||||
| 
						 | 
				
			
			@ -68,8 +69,13 @@ static inline void
 | 
			
		|||
point8(Imaging im, int x, int y, int ink) {
 | 
			
		||||
    if (x >= 0 && x < im->xsize && y >= 0 && y < im->ysize) {
 | 
			
		||||
        if (strncmp(im->mode, "I;16", 4) == 0) {
 | 
			
		||||
            im->image8[y][x * 2] = (UINT8)ink;
 | 
			
		||||
#ifdef WORDS_BIGENDIAN
 | 
			
		||||
            im->image8[y][x * 2] = (UINT8)(ink >> 8);
 | 
			
		||||
            im->image8[y][x * 2 + 1] = (UINT8)ink;
 | 
			
		||||
#else
 | 
			
		||||
            im->image8[y][x * 2] = (UINT8)ink;
 | 
			
		||||
            im->image8[y][x * 2 + 1] = (UINT8)(ink >> 8);
 | 
			
		||||
#endif
 | 
			
		||||
        } else {
 | 
			
		||||
            im->image8[y][x] = (UINT8)ink;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -634,7 +640,11 @@ DRAW draw32rgba = {point32rgba, hline32rgba, line32rgba, polygon32rgba};
 | 
			
		|||
#define DRAWINIT()                               \
 | 
			
		||||
    if (im->image8) {                            \
 | 
			
		||||
        draw = &draw8;                           \
 | 
			
		||||
        if (strncmp(im->mode, "I;16", 4) == 0) { \
 | 
			
		||||
            ink = INK16(ink_);                   \
 | 
			
		||||
        } else {                                 \
 | 
			
		||||
            ink = INK8(ink_);                    \
 | 
			
		||||
        }                                        \
 | 
			
		||||
    } else {                                     \
 | 
			
		||||
        draw = (op) ? &draw32rgba : &draw32;     \
 | 
			
		||||
        memcpy(&ink, ink_, sizeof(ink));         \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user