evgeniy778 commited on
Commit
56d4930
·
verified ·
1 Parent(s): d4d5379

Update tile_processor.py

Browse files
Files changed (1) hide show
  1. tile_processor.py +46 -39
tile_processor.py CHANGED
@@ -77,48 +77,55 @@ class TileProcessor:
77
 
78
  return tiles
79
 
80
- def create_output_canvas(
81
- self,
82
- image
83
- ):
84
-
85
- width, height = image.size
86
-
87
- return Image.new(
88
- "RGB",
89
- (
90
- width * self.scale,
91
- height * self.scale
92
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  )
94
 
95
- def paste_tile(
96
- self,
97
- canvas,
98
- tile_info,
99
- upscaled_tile
100
- ):
101
-
102
- x = tile_info["left"] * self.scale
103
- y = tile_info["top"] * self.scale
104
-
105
- if self.use_feather:
106
-
107
- print(
108
- f"Blend tile ({tile_info['left']}, {tile_info['top']})"
109
- )
110
-
111
- canvas.paste(
112
- upscaled_tile,
113
- (
114
- x,
115
- y
116
- )
117
  )
 
118
 
119
  def finish(
120
- self,
121
- canvas
122
- ):
123
 
124
- return canvas
 
77
 
78
  return tiles
79
 
80
+ def create_output_canvas(
81
+ self,
82
+ image
83
+ ):
84
+
85
+ width, height = image.size
86
+
87
+ return Image.new(
88
+ "RGBA",
89
+ (
90
+ width * self.scale,
91
+ height * self.scale
92
+ ),
93
+ (0, 0, 0, 0)
94
+ )
95
+
96
+ def paste_tile(
97
+ self,
98
+ canvas,
99
+ tile_info,
100
+ upscaled_tile
101
+ ):
102
+
103
+ x = tile_info["left"] * self.scale
104
+ y = tile_info["top"] * self.scale
105
+
106
+ if self.use_feather:
107
+
108
+ print(
109
+ f"Blend tile ({tile_info['left']}, {tile_info['top']})"
110
  )
111
 
112
+ #
113
+ # Пока готовим архитектуру.
114
+ # Следующим шагом здесь появится
115
+ # настоящее feather blending.
116
+ #
117
+
118
+ canvas.alpha_composite(
119
+ upscaled_tile.convert("RGBA"),
120
+ (
121
+ x,
122
+ y
 
 
 
 
 
 
 
 
 
 
 
123
  )
124
+ )
125
 
126
  def finish(
127
+ self,
128
+ canvas
129
+ ):
130
 
131
+ return canvas.convert("RGB")