Foglio di lavoro in immagine Imposta il formato del pixel per l immagine renderizzata
Contents
[
Hide
]
A volte si desidera specificare il formato pixel durante la resa di un foglio di lavoro in formato immagine. Per impostazione predefinita, Aspose.Cells per Python via .NET usa 32 bit per pixel. Aspose.Cells per Python via .NET consente di personalizzare il formato pixel (profondità di bit) utilizzando le opzioni per l’immagine renderizzata.
Si prega di consultare il codice di esempio di seguito che dimostra come impostare il formato del pixel desiderato durante la renderizzazione delle immagini dei fogli.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aspose.cells import Workbook | |
from aspose.cells.drawing import ImageType | |
from aspose.cells.rendering import ImageOrPrintOptions, SheetRender | |
from aspose.pydrawing.imaging import PixelFormat | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Source directory | |
sourceDir = RunExamples.Get_SourceDirectory() | |
# Output directory | |
outputDir = RunExamples.Get_OutputDirectory() | |
# Load an Excel file | |
wb = Workbook(sourceDir + "sampleSetPixelFormatRenderedImage.xlsx") | |
# Access first worksheet | |
ws = wb.worksheets[0] | |
# Set the ImageOrPrintOptions with desired pixel format (24 bits per pixel) and image format type | |
opts = ImageOrPrintOptions() | |
opts.pixel_format = PixelFormat.FORMAT_24BPP_RGB | |
opts.image_type = ImageType.TIFF | |
# Instantiate SheetRender object based on the first worksheet | |
sr = SheetRender(ws, opts) | |
# Save the image (first page of the sheet) with the specified options | |
sr.to_image(0, outputDir + "outputSetPixelFormatRenderedImage.tiff") |