def AddConvert(self): savePath = os.path.join(self.parent.savePath, ToolUtil.GetCanSaveName(self.epsTitle)) filePath = os.path.join( savePath, "{:04}.{}".format(self.curPreConvertId + 1, "jpg")) if not os.path.isfile(filePath): self.status = DownloadInfo.NotFound self.parent.SetConvertStatu(self.status) return isConvertNext = True while self.curPreConvertId < self.picCnt: if os.path.isfile(self.curConvertPath): self.curPreConvertId += 1 else: isConvertNext = False f = open(filePath, "rb") data = f.read() f.close() w, h = ToolUtil.GetPictureSize(data) model = ToolUtil.GetDownloadScaleModel(w, h) QtTask().AddConvertTask("", data, model, self.AddConvertBack, cleanFlag="download_{}".format( self.parent.bookId)) break self.parent.UpdateTableItem() if isConvertNext: self.StartConvert() return
def SetData(self, data, category): if not data: self.state = self.DownloadError return self.data = data self.w, self.h = ToolUtil.GetPictureSize(data) self.model = ToolUtil.GetLookScaleModel(self.w, self.h, category) self.state = self.DownloadSuc self.size = len(data)
def SetWaifuData(self, data, tick): if not data: self.waifuState = self.WaifuStateFail return self.waifuData = data self.waifuState = self.WaifuStateEnd self.waifuDataSize = len(self.waifuData) self.scaleW, self.scaleH = ToolUtil.GetPictureSize(data) self.waifuTick = tick return
def _ShowImg(self, data): self.scaleCnt = 0 self.pixMap = QPixmap() self.pixMap.loadFromData(data) self.show() self.graphicsItem.setPixmap(self.pixMap) self.graphicsView.setSceneRect(QRectF(QPointF(0, 0), QPointF(self.pixMap.width(), self.pixMap.height()))) size = ToolUtil.GetDownloadSize(len(data)) self.sizeLabel.setText(size) weight, height = ToolUtil.GetPictureSize(data) self.resolutionLabel.setText(str(weight) + "x" + str(height)) self.ScalePicture()
def AddConvert(self): savePath = os.path.join(self.parent.savePath, ToolUtil.GetCanSaveName(self.epsTitle)) filePath = os.path.join(savePath, "{:04}.{}".format(self.curPreConvertId + 1, "jpg")) if not os.path.isfile(filePath): self.status = DownloadInfo.Error self.parent.SetConvertStatu(self.status) return if os.path.isfile(self.curConvertPath): self.curPreConvertId += 1 return self.StartConvert() f = open(filePath, "rb") data = f.read() f.close() w, h = ToolUtil.GetPictureSize(data) model = ToolUtil.GetDownloadScaleModel(w, h) QtTask().AddConvertTask("", data, model, self.AddConvertBack, cleanFlag="download_".format(self.parent.bookId)) return