(self, width, height)
| 232 | return factorX, factorY |
| 233 | |
| 234 | def UpdateCachedImage(self, width, height): |
| 235 | # print("UpdateCachedImage: ", width, " " , height) |
| 236 | self.CachedImage = QImage( |
| 237 | width, height, QImage.Format_ARGB32_Premultiplied) |
| 238 | self.CachedImage.fill(QColor(0, 0, 0, 0)) |
| 239 | painter = QPainter(self.CachedImage) |
| 240 | factorX = 0.0 |
| 241 | factorY = 0.0 |
| 242 | factorX, factorY = self.GetFactor(width, height, factorX, factorY) |
| 243 | # print("after GetFactor: ", width, height, factorX, factorY) |
| 244 | lostX = 0.0 |
| 245 | lostY = 0.0 |
| 246 | x1 = 0 # for image parts X |
| 247 | y1 = 0 # for image parts Y |
| 248 | # widthResize # width for image parts |
| 249 | # heightResize # height for image parts |
| 250 | resizeX = 0 |
| 251 | resizeY = 0 |
| 252 | offsetX = 0 |
| 253 | offsetY = 0 |
| 254 | for i in range(len(self.ResizeDistancesX)): |
| 255 | y1 = 0 |
| 256 | offsetY = 0 |
| 257 | lostY = 0.0 |
| 258 | for j in range(len(self.ResizeDistancesY)): |
| 259 | widthResize = self.ResizeDistancesX[i][0] - x1 |
| 260 | heightResize = self.ResizeDistancesY[j][0] - y1 |
| 261 | |
| 262 | self.DrawConstPart(QRect(x1 + 1, y1 + 1, widthResize, heightResize), |
| 263 | QRect(x1 + offsetX, y1 + offsetY, widthResize, heightResize), painter) |
| 264 | |
| 265 | y2 = self.ResizeDistancesY[j][0] |
| 266 | heightResize = self.ResizeDistancesY[j][1] |
| 267 | resizeY = round(float(heightResize) * factorY) |
| 268 | lostY += resizeY - (float(heightResize) * factorY) |
| 269 | if (fabs(lostY) >= 1.0): |
| 270 | if (lostY < 0): |
| 271 | resizeY += 1 |
| 272 | lostY += 1.0 |
| 273 | else: |
| 274 | resizeY -= 1 |
| 275 | lostY -= 1.0 |
| 276 | |
| 277 | self.DrawScaledPart(QRect(x1 + 1, y2 + 1, widthResize, heightResize), |
| 278 | QRect(x1 + offsetX, y2 + offsetY, widthResize, resizeY), painter) |
| 279 | |
| 280 | x2 = self.ResizeDistancesX[i][0] |
| 281 | widthResize = self.ResizeDistancesX[i][1] |
| 282 | heightResize = self.ResizeDistancesY[j][0] - y1 |
| 283 | resizeX = round(float(widthResize) * factorX) |
| 284 | lostX += resizeX - (float(widthResize) * factorX) |
| 285 | if (fabs(lostX) >= 1.0): |
| 286 | if (lostX < 0): |
| 287 | resizeX += 1 |
| 288 | lostX += 1.0 |
| 289 | else: |
| 290 | resizeX -= 1 |
| 291 | lostX -= 1.0 |
no test coverage detected