Exemplo n.º 1
0
 def updateForImageSelection(self):
     pixelWidth = 0
     pixelHeight = 0
     screenColorBits = 0
     screenColors = 0L
     inchWidth = 0.0
     inchHeight = 0.0
     screenDC = HDC()
     megabytesNeeded = 0.0
     
     self.updateSelectionRectFromMainWindow()
     # fill in labels
     pixelWidth = usupport.rWidth(self.selectionRectFromMainWindow)
     pixelHeight = usupport.rHeight(self.selectionRectFromMainWindow)
     inchWidth = umath.safedivExcept(pixelWidth, delphi_compatability.Screen.PixelsPerInch, 0)
     inchHeight = umath.safedivExcept(pixelHeight, delphi_compatability.Screen.PixelsPerInch, 0)
     self.selectedImageInfoLabel.Caption = "Selection:  " + IntToStr(pixelWidth) + " x " + IntToStr(pixelHeight) + " pixels,  " + floatStr(inchWidth) + " x " + floatStr(inchHeight) + " inches"
     screenDC = UNRESOLVED.GetDC(0)
     try:
         screenColorBits = (UNRESOLVED.GetDeviceCaps(screenDC, delphi_compatability.BITSPIXEL) * UNRESOLVED.GetDeviceCaps(screenDC, delphi_compatability.PLANES))
     finally:
         UNRESOLVED.ReleaseDC(0, screenDC)
     if screenColorBits != 32:
         screenColors = 1 << screenColorBits
         self.screenInfoLabel.Caption = "Screen:  " + IntToStr(delphi_compatability.Screen.PixelsPerInch) + " pixels/inch,  " + IntToStr(screenColors) + " colors (" + IntToStr(screenColorBits) + " bits)"
     else:
         self.screenInfoLabel.Caption = "Screen:  " + IntToStr(delphi_compatability.Screen.PixelsPerInch) + " pixels/inch,  " + "true color (" + IntToStr(screenColorBits) + " bits)"
     # used to be only in suggest size button, now doing automatically
     self.setValue(self.inchWidthEdit, inchWidth)
     self.setValue(self.inchHeightEdit, inchHeight)
     self.calculatePixelsFromResolutionAndInches()
     if self.copySavePrintType == kPrintingDrawing:
         self.suggestPrintSizeClick(self)
         self.updatePrintPreview()
     self.reportOnMemoryNeeded()
Exemplo n.º 2
0
 def calculateResolutionFromInchesAndPixels(self):
     xRes = 0.0
     yRes = 0.0
     
     xRes = umath.safedivExcept(self.pictureWidth_px, self.pictureWidth_in, delphi_compatability.Screen.PixelsPerInch)
     yRes = umath.safedivExcept(self.pictureHeight_px, self.pictureHeight_in, delphi_compatability.Screen.PixelsPerInch)
     self.setValue(self.resolutionEdit, intround(umath.min(xRes, yRes)))
     self.calculatePixelsFromResolutionAndInches()
Exemplo n.º 3
0
 def calculateNumberOfFrames(self):
     scaleMultiplier = 0.0
     
     if self.options.animateBy == udomain.kAnimateByAge:
         self.plantMaxAgeLabel.Caption = "Maximum age = " + IntToStr(self.plant.pGeneral.ageAtMaturity)
         self.plantMaxAgeLabel.Visible = true
         self.options.frameCount = self.plant.pGeneral.ageAtMaturity / self.options.ageIncrement + 1
     elif self.options.animateBy == udomain.kAnimateByXRotation:
         self.plantMaxAgeLabel.Visible = false
         self.options.frameCount = 360 / abs(self.options.xRotationIncrement)
     self.fileNumberLabel.Caption = "Number of files:  " + IntToStr(self.options.frameCount)
     scaleMultiplier = umath.safedivExcept(1.0 * self.options.resolution_pixelsPerInch, 1.0 * delphi_compatability.Screen.PixelsPerInch, 1.0)
     self.options.scaledSize = Point(intround(usupport.rWidth(self.plant.boundsRect_pixels()) * scaleMultiplier), intround(usupport.rHeight(self.plant.boundsRect_pixels()) * scaleMultiplier))
     self.animationSizeLabel.Caption = "Animation size:  " + IntToStr(self.options.scaledSize.X) + " x " + IntToStr(self.options.scaledSize.Y)
     self.options.fileSize = intround(self.options.frameCount * self.options.scaledSize.X * self.options.scaledSize.Y * usupport.bitsPerPixelForColorType(self.options.colorType) / 8.0) + FIX_sizeof(delphi_compatability.TBitmapInfo)
     if self.options.fileSize < 1024:
         self.fileSizeLabel.Caption = "Estimated total size:  " + IntToStr(self.options.fileSize) + " bytes"
     elif self.options.fileSize < 1024 * 1024:
         self.fileSizeLabel.Caption = "Estimated total size:  " + IntToStr(self.options.fileSize / 1024) + " KB"
     else:
         self.fileSizeLabel.Caption = "Estimated total size:  " + FloatToStrF(self.options.fileSize / (1024 * 1024), UNRESOLVED.ffFixed, 7, 1) + " MB"
     if self.options.fileSize >= 10.0 * 1024 * 1024:
         self.fileSizeLabel.Font.Style = [UNRESOLVED.fsBold, ]
     else:
         self.fileSizeLabel.Font.Style = []
Exemplo n.º 4
0
 def updateCellSizeAndCountForSelection(self):
     excludeInvisiblePlants = false
     excludeNonSelectedPlants = false
     cellRect = TRect()
     scaleMultiplier = 0.0
     fileSize = 0L
     
     excludeInvisiblePlants = not self.useAllPlants.Checked
     excludeNonSelectedPlants = self.useSelectedPlants.Checked
     cellRect = udomain.domain.plantManager.largestPlantBoundsRect(umain.MainForm.selectedPlants, excludeInvisiblePlants, excludeNonSelectedPlants)
     scaleMultiplier = umath.safedivExcept(1.0 * self.options.resolution_pixelsPerInch, 1.0 * delphi_compatability.Screen.PixelsPerInch, 1.0)
     self.options.cellSize = Point(intround(usupport.rWidth(cellRect) * scaleMultiplier), intround(usupport.rHeight(cellRect) * scaleMultiplier))
     if self.useAllPlants.Checked:
         self.options.cellCount = udomain.domain.plantManager.plants.Count
     elif self.useVisiblePlants.Checked:
         self.options.cellCount = udomain.domain.plantManager.visiblePlantCount()
     elif self.useSelectedPlants.Checked:
         self.options.cellCount = umain.MainForm.selectedPlants.Count
     self.cellSizeLabel.Caption = "Nozzle/tube cell width:  " + IntToStr(self.options.cellSize.X) + " height:  " + IntToStr(self.options.cellSize.Y)
     self.cellCountLabel.Caption = "Number of items:  " + IntToStr(self.options.cellCount)
     fileSize = intround(self.options.cellCount * self.options.cellSize.X * self.options.cellSize.Y * usupport.bitsPerPixelForColorType(self.options.colorType) / 8.0) + FIX_sizeof(delphi_compatability.TBitmapInfo)
     if fileSize < 1024:
         self.fileSizeLabel.Caption = "Estimated file size:  " + IntToStr(fileSize) + " bytes"
     elif fileSize < 1024 * 1024:
         self.fileSizeLabel.Caption = "Estimated file size:  " + IntToStr(fileSize / 1024) + " KB"
     else:
         self.fileSizeLabel.Caption = "Estimated file size:  " + FloatToStrF(fileSize / (1024 * 1024), UNRESOLVED.ffFixed, 7, 1) + " MB"
     if fileSize >= 10.0 * 1024 * 1024:
         self.fileSizeLabel.Font.Style = [UNRESOLVED.fsBold, ]
     else:
         self.fileSizeLabel.Font.Style = []
Exemplo n.º 5
0
 def suggestPrintSizeClick(self, Sender):
     bestMargin_in = 0.0
     bestWidth_in = 0.0
     bestHeight_in = 0.0
     newWidth_in = 0.0
     newHeight_in = 0.0
     maxMinMargin_in = 0.0
     
     # calculate best margin: for 10 inches, 1.0 inches, for 5 inches, 0.5 inches;
     # keep to multiples of 0.25 inches
     maxMinMargin_in = umath.max(self.printMinMarginLeft_in, umath.max(self.printMinMarginTop_in, umath.max(self.printMinMarginRight_in, self.printMinMarginBottom_in)))
     bestMargin_in = umath.max(maxMinMargin_in, intround(4.0 * umath.min(self.wholePageWidth_in, self.wholePageHeight_in) / 10.0) / 4.0)
     bestWidth_in = self.wholePageWidth_in - bestMargin_in * 2
     bestHeight_in = self.wholePageHeight_in - bestMargin_in * 2
     # preserve aspect ratio - reduce the larger dimension so it still fits on the page
     self.updateSelectionRectFromMainWindow()
     newHeight_in = bestHeight_in
     newWidth_in = bestHeight_in * self.aspectRatio
     if newWidth_in > bestWidth_in:
         newWidth_in = bestWidth_in
         newHeight_in = umath.safedivExcept(bestWidth_in, self.aspectRatio, bestHeight_in)
     # set original picture size to fit on page using printer resolution
     self.setValue(self.inchWidthEdit, newWidth_in)
     self.setValue(self.inchHeightEdit, newHeight_in)
     self.setValue(self.resolutionEdit, self.smallestPrintResolution_pxPin)
     self.calculatePixelsFromResolutionAndInches()
     # set print size same as picture size
     self.setValue(self.printWidthEdit, newWidth_in)
     self.setValue(self.printHeightEdit, newHeight_in)
     # center picture
     self.printCenterClick(self)
Exemplo n.º 6
0
 def updatePrintPreview(self):
     scaleX_pxPin = 0.0
     scaleY_pxPin = 0.0
     scale_pxPin = 0.0
     borderThickness_in = 0.0
     availableWidth_px = 0
     availableHeight_px = 0
     marginRect = TRect()
     
     availableWidth_px = self.sizeLabel.Left - self.wholePageImage.Left - 10
     availableHeight_px = self.printBox.Height - self.wholePageImage.Top - 10
     scaleX_pxPin = umath.safedivExcept(1.0 * availableWidth_px, self.wholePageWidth_in, 5)
     scaleY_pxPin = umath.safedivExcept(1.0 * availableHeight_px, self.wholePageHeight_in, 5)
     scale_pxPin = umath.min(scaleX_pxPin, scaleY_pxPin)
     self.wholePageImage.Width = intround(self.wholePageWidth_in * scale_pxPin)
     self.wholePageImage.Height = intround(self.wholePageHeight_in * scale_pxPin)
     if (self.wholePageImage.Picture.Bitmap.Width != self.wholePageImage.Width) or (self.wholePageImage.Picture.Bitmap.Height != self.wholePageImage.Height):
         try:
             self.wholePageImage.Picture.Bitmap.Width = self.wholePageImage.Width
             self.wholePageImage.Picture.Bitmap.Height = self.wholePageImage.Height
         except:
             self.wholePageImage.Picture.Bitmap.Width = 1
             self.wholePageImage.Picture.Bitmap.Height = 1
     marginRect.Left = intround(self.printMinMarginLeft_in * scale_pxPin)
     marginRect.Top = intround(self.printMinMarginTop_in * scale_pxPin)
     # subtract 1 from right and bottom because last pixel is not drawn
     marginRect.Right = self.wholePageImage.Width - intround(self.printMinMarginRight_in * scale_pxPin) - 1
     marginRect.Bottom = self.wholePageImage.Height - intround(self.printMinMarginBottom_in * scale_pxPin) - 1
     self.wholePageImage.Picture.Bitmap.Canvas.Brush.Color = delphi_compatability.clWindow
     self.wholePageImage.Picture.Bitmap.Canvas.FillRect(Rect(0, 0, self.wholePageImage.Width, self.wholePageImage.Height))
     self.wholePageImage.Picture.Bitmap.Canvas.Brush.Style = delphi_compatability.TFPBrushStyle.bsClear
     self.wholePageImage.Picture.Bitmap.Canvas.Pen.Color = UNRESOLVED.clBtnShadow
     self.wholePageImage.Picture.Bitmap.Canvas.MoveTo(0, marginRect.Top)
     self.wholePageImage.Picture.Bitmap.Canvas.LineTo(self.wholePageImage.Width, marginRect.Top)
     self.wholePageImage.Picture.Bitmap.Canvas.MoveTo(marginRect.Left, 0)
     self.wholePageImage.Picture.Bitmap.Canvas.LineTo(marginRect.Left, self.wholePageImage.Height)
     self.wholePageImage.Picture.Bitmap.Canvas.MoveTo(marginRect.Right, 0)
     self.wholePageImage.Picture.Bitmap.Canvas.LineTo(marginRect.Right, self.wholePageImage.Height)
     self.wholePageImage.Picture.Bitmap.Canvas.MoveTo(0, marginRect.Bottom)
     self.wholePageImage.Picture.Bitmap.Canvas.LineTo(self.wholePageImage.Width, marginRect.Bottom)
     self.wholePageImage.Picture.Bitmap.Canvas.Pen.Style = delphi_compatability.TFPPenStyle.psSolid
     self.wholePageImage.Picture.Bitmap.Canvas.Rectangle(0, 0, self.wholePageImage.Width, self.wholePageImage.Height)
     borderThickness_in = umath.safedivExcept(self.options.borderThickness, self.smallestPrintResolution_pxPin, 0)
     self.printImagePanel.SetBounds(intround(self.wholePageImage.Left + (self.printLeftMargin_in - borderThickness_in) * scale_pxPin), intround(self.wholePageImage.Top + (self.printTopMargin_in - borderThickness_in) * scale_pxPin), intround((self.printWidth_in + borderThickness_in * 2) * scale_pxPin), intround((self.printHeight_in + borderThickness_in * 2) * scale_pxPin))
Exemplo n.º 7
0
 def fractionLive(self):
     result = 0.0
     result = 0.0
     try:
         if self.totalBiomass_pctMPB() > 0.0:
             result = umath.safedivExcept(self.liveBiomass_pctMPB, self.totalBiomass_pctMPB(), 0)
         else:
             result = 0.0
     except Exception, e:
         usupport.messageForExceptionType(e, "PdPlantPart.fractionLive")
Exemplo n.º 8
0
def linearGrowthWithFactor(current, optimal, minDays, growthFactor):
    amountNeeded = 0.0
    maxPossible = 0.0

    try:
        amountNeeded = optimal - current
        maxPossible = umath.safedivExcept(optimal, minDays, optimal)
        amountNeeded = max(0.0, min(amountNeeded, maxPossible))
        current = current + amountNeeded * growthFactor
    except Exception, e:
        usupport.messageForExceptionType(e, "linearGrowthWithFactor")
Exemplo n.º 9
0
def linearGrowthWithFactor(current, optimal, minDays, growthFactor):
    amountNeeded = 0.0
    maxPossible = 0.0
    
    try:
        amountNeeded = optimal - current
        maxPossible = umath.safedivExcept(optimal, minDays, optimal)
        amountNeeded = umath.max(0.0, umath.min(amountNeeded, maxPossible))
        current = current + amountNeeded * growthFactor
    except Exception, e:
        usupport.messageForExceptionType(e, "linearGrowthWithFactor")
Exemplo n.º 10
0
 def fractionLive(self):
     result = 0.0
     result = 0.0
     try:
         if self.totalBiomass_pctMPB() > 0.0:
             result = umath.safedivExcept(self.liveBiomass_pctMPB,
                                          self.totalBiomass_pctMPB(), 0)
         else:
             result = 0.0
     except Exception, e:
         usupport.messageForExceptionType(e, "PdPlantPart.fractionLive")
Exemplo n.º 11
0
 def updateSelectionRectFromMainWindow(self):
     excludeInvisiblePlants = false
     excludeNonSelectedPlants = false
     
     excludeInvisiblePlants = not self.useAllPlants.Checked
     excludeNonSelectedPlants = self.useSelectedPlants.Checked
     if self.useDrawingAreaContents.Checked:
         self.selectionRectFromMainWindow = Rect(0, 0, umain.MainForm.drawingPaintBox.Width, umain.MainForm.drawingPaintBox.Height)
     else:
         self.selectionRectFromMainWindow = udomain.domain.plantManager.combinedPlantBoundsRects(umain.MainForm.selectedPlants, excludeInvisiblePlants, excludeNonSelectedPlants)
     self.aspectRatio = umath.safedivExcept(usupport.rWidth(self.selectionRectFromMainWindow), usupport.rHeight(self.selectionRectFromMainWindow), 1.0)
Exemplo n.º 12
0
def linearGrowthResult(current, optimal, minDays):
    result = 0.0
    amountNeeded = 0.0
    maxPossible = 0.0

    result = 0.0
    try:
        amountNeeded = optimal - current
        maxPossible = umath.safedivExcept(optimal, minDays, optimal)
        amountNeeded = max(0.0, min(amountNeeded, maxPossible))
        result = amountNeeded
    except Exception, e:
        usupport.messageForExceptionType(e, "linearGrowthResult")
Exemplo n.º 13
0
def linearGrowthResult(current, optimal, minDays):
    result = 0.0
    amountNeeded = 0.0
    maxPossible = 0.0
    
    result = 0.0
    try:
        amountNeeded = optimal - current
        maxPossible = umath.safedivExcept(optimal, minDays, optimal)
        amountNeeded = umath.max(0.0, umath.min(amountNeeded, maxPossible))
        result = amountNeeded
    except Exception, e:
        usupport.messageForExceptionType(e, "linearGrowthResult")
Exemplo n.º 14
0
    def updateCellSizeAndCountForSelection(self):
        excludeInvisiblePlants = false
        excludeNonSelectedPlants = false
        cellRect = TRect()
        scaleMultiplier = 0.0
        fileSize = 0L

        excludeInvisiblePlants = not self.useAllPlants.Checked
        excludeNonSelectedPlants = self.useSelectedPlants.Checked
        cellRect = udomain.domain.plantManager.largestPlantBoundsRect(
            umain.MainForm.selectedPlants, excludeInvisiblePlants,
            excludeNonSelectedPlants)
        scaleMultiplier = umath.safedivExcept(
            1.0 * self.options.resolution_pixelsPerInch,
            1.0 * delphi_compatability.Screen.PixelsPerInch, 1.0)
        self.options.cellSize = Point(
            intround(usupport.rWidth(cellRect) * scaleMultiplier),
            intround(usupport.rHeight(cellRect) * scaleMultiplier))
        if self.useAllPlants.Checked:
            self.options.cellCount = udomain.domain.plantManager.plants.Count
        elif self.useVisiblePlants.Checked:
            self.options.cellCount = udomain.domain.plantManager.visiblePlantCount(
            )
        elif self.useSelectedPlants.Checked:
            self.options.cellCount = umain.MainForm.selectedPlants.Count
        self.cellSizeLabel.Caption = "Nozzle/tube cell width:  " + IntToStr(
            self.options.cellSize.X) + " height:  " + IntToStr(
                self.options.cellSize.Y)
        self.cellCountLabel.Caption = "Number of items:  " + IntToStr(
            self.options.cellCount)
        fileSize = intround(
            self.options.cellCount * self.options.cellSize.X *
            self.options.cellSize.Y *
            usupport.bitsPerPixelForColorType(self.options.colorType) /
            8.0) + FIX_sizeof(delphi_compatability.TBitmapInfo)
        if fileSize < 1024:
            self.fileSizeLabel.Caption = "Estimated file size:  " + IntToStr(
                fileSize) + " bytes"
        elif fileSize < 1024 * 1024:
            self.fileSizeLabel.Caption = "Estimated file size:  " + IntToStr(
                fileSize / 1024) + " KB"
        else:
            self.fileSizeLabel.Caption = "Estimated file size:  " + FloatToStrF(
                fileSize / (1024 * 1024), UNRESOLVED.ffFixed, 7, 1) + " MB"
        if fileSize >= 10.0 * 1024 * 1024:
            self.fileSizeLabel.Font.Style = [
                UNRESOLVED.fsBold,
            ]
        else:
            self.fileSizeLabel.Font.Style = []
Exemplo n.º 15
0
 def resizePrintBasedOnAspectRatio(self, whatWasChanged):
     newWidth_in = 0.0
     newHeight_in = 0.0
     newRight_in = 0.0
     newBottom_in = 0.0
     maxWidth_in = 0.0
     maxHeight_in = 0.0
     
     newWidth_in = self.printWidth_in
     newHeight_in = self.printHeight_in
     self.updateSelectionRectFromMainWindow()
     if whatWasChanged == kHeightWasChanged:
         newWidth_in = newHeight_in * self.aspectRatio
     elif whatWasChanged == kWidthWasChanged:
         newHeight_in = umath.safedivExcept(newWidth_in, self.aspectRatio, newHeight_in)
     elif whatWasChanged == kHeightAndWidthWereChanged:
         if newWidth_in > newHeight_in:
             newWidth_in = newHeight_in * self.aspectRatio
         else:
             newHeight_in = umath.safedivExcept(newWidth_in, self.aspectRatio, newHeight_in)
     # bound size at page, using left/top margins already set
     maxWidth_in = self.wholePageWidth_in - self.printLeftMargin_in - self.printMinMarginRight_in
     maxHeight_in = self.wholePageHeight_in - self.printTopMargin_in - self.printMinMarginBottom_in
     if newWidth_in > maxWidth_in:
         newWidth_in = maxWidth_in
         newHeight_in = umath.safedivExcept(newWidth_in, self.aspectRatio, newHeight_in)
     if newHeight_in > maxHeight_in:
         newHeight_in = maxHeight_in
         newWidth_in = newHeight_in * self.aspectRatio
     newRight_in = umath.max(self.printMinMarginRight_in, self.wholePageWidth_in - self.printLeftMargin_in - newWidth_in)
     newBottom_in = umath.max(self.printMinMarginBottom_in, self.wholePageHeight_in - self.printTopMargin_in - newHeight_in)
     # set values in edits
     self.setValue(self.printWidthEdit, newWidth_in)
     self.setValue(self.printHeightEdit, newHeight_in)
     self.setValue(self.printRightMarginEdit, newRight_in)
     self.setValue(self.printBottomMarginEdit, newBottom_in)
     self.updatePrintPreview()
Exemplo n.º 16
0
 def printUseWholePageClick(self, Sender):
     borderThickness_in = 0.0
     
     borderThickness_in = umath.safedivExcept(self.options.borderThickness, self.smallestPrintResolution_pxPin, 0)
     self.setValue(self.printLeftMarginEdit, self.printMinMarginLeft_in + borderThickness_in)
     self.setValue(self.printRightMarginEdit, self.printMinMarginRight_in + borderThickness_in)
     self.setValue(self.printTopMarginEdit, self.printMinMarginTop_in + borderThickness_in)
     self.setValue(self.printBottomMarginEdit, self.printMinMarginBottom_in + borderThickness_in)
     self.setValue(self.printWidthEdit, self.wholePageWidth_in - self.printLeftMargin_in - self.printRightMargin_in)
     self.setValue(self.printHeightEdit, self.wholePageHeight_in - self.printTopMargin_in - self.printBottomMargin_in)
     if self.printPreserveAspectRatio.Checked:
         # check new size for aspect ratio (if 'preserve aspect ratio' checked)
         self.resizePrintBasedOnAspectRatio(kHeightAndWidthWereChanged)
     else:
         self.updatePrintPreview()
Exemplo n.º 17
0
    def calculateNumberOfFrames(self):
        scaleMultiplier = 0.0

        if self.options.animateBy == udomain.kAnimateByAge:
            self.plantMaxAgeLabel.Caption = "Maximum age = " + IntToStr(
                self.plant.pGeneral.ageAtMaturity)
            self.plantMaxAgeLabel.Visible = true
            self.options.frameCount = self.plant.pGeneral.ageAtMaturity / self.options.ageIncrement + 1
        elif self.options.animateBy == udomain.kAnimateByXRotation:
            self.plantMaxAgeLabel.Visible = false
            self.options.frameCount = 360 / abs(
                self.options.xRotationIncrement)
        self.fileNumberLabel.Caption = "Number of files:  " + IntToStr(
            self.options.frameCount)
        scaleMultiplier = umath.safedivExcept(
            1.0 * self.options.resolution_pixelsPerInch,
            1.0 * delphi_compatability.Screen.PixelsPerInch, 1.0)
        self.options.scaledSize = Point(
            intround(
                usupport.rWidth(self.plant.boundsRect_pixels()) *
                scaleMultiplier),
            intround(
                usupport.rHeight(self.plant.boundsRect_pixels()) *
                scaleMultiplier))
        self.animationSizeLabel.Caption = "Animation size:  " + IntToStr(
            self.options.scaledSize.X) + " x " + IntToStr(
                self.options.scaledSize.Y)
        self.options.fileSize = intround(
            self.options.frameCount * self.options.scaledSize.X *
            self.options.scaledSize.Y *
            usupport.bitsPerPixelForColorType(self.options.colorType) /
            8.0) + FIX_sizeof(delphi_compatability.TBitmapInfo)
        if self.options.fileSize < 1024:
            self.fileSizeLabel.Caption = "Estimated total size:  " + IntToStr(
                self.options.fileSize) + " bytes"
        elif self.options.fileSize < 1024 * 1024:
            self.fileSizeLabel.Caption = "Estimated total size:  " + IntToStr(
                self.options.fileSize / 1024) + " KB"
        else:
            self.fileSizeLabel.Caption = "Estimated total size:  " + FloatToStrF(
                self.options.fileSize /
                (1024 * 1024), UNRESOLVED.ffFixed, 7, 1) + " MB"
        if self.options.fileSize >= 10.0 * 1024 * 1024:
            self.fileSizeLabel.Font.Style = [
                UNRESOLVED.fsBold,
            ]
        else:
            self.fileSizeLabel.Font.Style = []
Exemplo n.º 18
0
 def updateForPrinterInfo(self):
     xResolution_pixelsPerInch = 0
     yResolution_pixelsPerInch = 0
     portraitOrLandscape = ""
     printerDC = HDC()
     printerColorBits = 0
     printerColors = 0
     
     xResolution_pixelsPerInch = UNRESOLVED.GetDeviceCaps(UNRESOLVED.Printer.Handle, delphi_compatability.LOGPIXELSX)
     yResolution_pixelsPerInch = UNRESOLVED.GetDeviceCaps(UNRESOLVED.Printer.Handle, delphi_compatability.LOGPIXELSY)
     self.smallestPrintResolution_pxPin = umath.intMin(xResolution_pixelsPerInch, yResolution_pixelsPerInch)
     self.printPageWidth_in = umath.safedivExcept(UNRESOLVED.Printer.pageWidth - 1, xResolution_pixelsPerInch, 0)
     self.printPageHeight_in = umath.safedivExcept(UNRESOLVED.Printer.pageHeight - 1, yResolution_pixelsPerInch, 0)
     self.wholePageWidth_in = umath.safedivExcept(UNRESOLVED.GetDeviceCaps(UNRESOLVED.Printer.Handle, UNRESOLVED.PHYSICALWIDTH), xResolution_pixelsPerInch, 0)
     self.wholePageHeight_in = umath.safedivExcept(UNRESOLVED.GetDeviceCaps(UNRESOLVED.Printer.Handle, UNRESOLVED.PHYSICALHEIGHT), xResolution_pixelsPerInch, 0)
     self.printMinMarginLeft_in = umath.safedivExcept(UNRESOLVED.GetDeviceCaps(UNRESOLVED.Printer.Handle, UNRESOLVED.PhysicalOffsetX), xResolution_pixelsPerInch, 0)
     self.printMinMarginTop_in = umath.safedivExcept(UNRESOLVED.GetDeviceCaps(UNRESOLVED.Printer.Handle, UNRESOLVED.PhysicalOffsetY), xResolution_pixelsPerInch, 0)
     self.printMinMarginRight_in = self.wholePageWidth_in - self.printPageWidth_in - self.printMinMarginLeft_in
     self.printMinMarginBottom_in = self.wholePageHeight_in - self.printPageHeight_in - self.printMinMarginTop_in
     if UNRESOLVED.Printer.orientation == UNRESOLVED.poPortrait:
         portraitOrLandscape = "Portrait"
     else:
         portraitOrLandscape = "Landscape"
     printerDC = UNRESOLVED.CreateCompatibleDC(UNRESOLVED.Printer.Handle)
     try:
         printerColorBits = (UNRESOLVED.GetDeviceCaps(printerDC, delphi_compatability.BITSPIXEL) * UNRESOLVED.GetDeviceCaps(printerDC, delphi_compatability.PLANES))
     finally:
         UNRESOLVED.ReleaseDC(0, printerDC)
         UNRESOLVED.DeleteDC(printerDC)
     if printerColorBits != 32:
         printerColors = 1 << printerColorBits
     else:
         printerColors = intround(umath.power(2.0, printerColorBits))
     self.printerOrFileTypeInfoLabel.Caption = "Printer:  " + IntToStr(UNRESOLVED.GetDeviceCaps(UNRESOLVED.Printer.Handle, delphi_compatability.LOGPIXELSX)) + " x " + IntToStr(UNRESOLVED.GetDeviceCaps(UNRESOLVED.Printer.Handle, delphi_compatability.LOGPIXELSY)) + " pixels/inch, " + IntToStr(printerColors) + " colors (" + IntToStr(printerColorBits) + " bits)"
     #+ portraitOrLandscape;
     #printerInfoLabel.hint := 'Printer name: ' + Printer.Printers[Printer.printerIndex];
     self.updatePrintPreview()
Exemplo n.º 19
0
 def calculateInchesFromResolutionAndPixels(self):
     self.setValue(self.inchWidthEdit, umath.safedivExcept(1.0 * self.pictureWidth_px, 1.0 * self.pictureResolution_pxPin, 0))
     self.setValue(self.inchHeightEdit, umath.safedivExcept(1.0 * self.pictureHeight_px, 1.0 * self.pictureResolution_pxPin, 0))
Exemplo n.º 20
0
 def heightForWidthAndAspectRatio(self, width, ratio):
     result = 0.0
     result = umath.safedivExcept(width, ratio, 0)
     return result