Leggere in inglese

Condividi tramite


XpsImage Classe

Definizione

Rappresenta un'immagine in un XpsDocument.

public class XpsImage : System.Windows.Xps.Packaging.XpsResource
Ereditarietà

Esempio

Nell'esempio seguente viene illustrato come aggiungere immagini a un XpsDocumentoggetto .

// -------------------------- AddPageResources ----------------------------
private Dictionary<string, List<XpsResource>>
        AddPageResources(IXpsFixedPageWriter fixedPageWriter)
{
    // Collection of all resources for this page.
    //   Key: "XpsImage", "XpsFont"
    //   Value: List of XpsImage or XpsFont
    Dictionary<string, List<XpsResource>> resources =
        new Dictionary<string, List<XpsResource>>();

    // Collections of images and fonts used in the current page.
    List<XpsResource> xpsImages = new List<XpsResource>();
    List<XpsResource> xpsFonts  = new List<XpsResource>();

    try
    {
        XpsImage xpsImage;
        XpsFont  xpsFont;

        // Add, Write, and Commit image1 to the current page.
        xpsImage = fixedPageWriter.AddImage(XpsImageType.JpegImageType);
        WriteToStream(xpsImage.GetStream(), image1);
        xpsImage.Commit();
        xpsImages.Add(xpsImage);    // Add image1 as a required resource.

        // Add, Write, and Commit font 1 to the current page.
        xpsFont = fixedPageWriter.AddFont();
        WriteObfuscatedStream(
            xpsFont.Uri.ToString(), xpsFont.GetStream(), font1);
        xpsFont.Commit();
        xpsFonts.Add(xpsFont);      // Add font1 as a required resource.

        // Add, Write, and Commit image2 to the current page.
        xpsImage = fixedPageWriter.AddImage(XpsImageType.TiffImageType);
        WriteToStream(xpsImage.GetStream(), image2);
        xpsImage.Commit();
        xpsImages.Add(xpsImage);    // Add image2 as a required resource.

        // Add, Write, and Commit font2 to the current page.
        xpsFont = fixedPageWriter.AddFont(false);
        WriteToStream(xpsFont.GetStream(), font2);
        xpsFont.Commit();
        xpsFonts.Add(xpsFont);      // Add font2 as a required resource.

        // Return the image and font resources in a combined collection.
        resources.Add("XpsImage", xpsImages);
        resources.Add("XpsFont", xpsFonts);
        return resources;
    }
    catch (XpsPackagingException xpsException)
    {
        throw xpsException;
    }
}// end:AddPageResources()

Commenti

La XpsImage classe non ha alcun costruttore pubblico.

Usare il AddImage metodo per aggiungere un'immagine e ottenere un riferimento a esso in un nuovo documento.

Usare il GetImage metodo per ottenere un riferimento all'immagine in un documento esistente.

In base alle impostazioni di XpsSerializationManager e , ad FontSubsetterCommitPolicies esempio e PackageInterleavingOrderXpsPackagingPolicy, l'operazione di scaricamento del Commit metodo della XpsImage classe può essere ritardata fino alla chiusura del completamentoXpsDocument.

Proprietà

Uri

Ottiene o imposta l'URI (Uniform Resource Identifier) della parte.

(Ereditato da XpsPartBase)

Metodi

Commit()

Esegue il commit di tutte le modifiche e scarica la risorsa nel pacchetto del documento.

(Ereditato da XpsResource)
Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetStream()

Quando viene sottoposto a override in una classe derivata, restituisce il flusso di I/O per la lettura o la scrittura della risorsa.

(Ereditato da XpsResource)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
RelativeUri(Uri)

Restituisce l'URI della risorsa relativo a un URI assoluto specificato.

(Ereditato da XpsResource)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Implementazioni dell'interfaccia esplicita

IDisposable.Dispose()

Questo membro supporta l'infrastruttura Windows Presentation Foundation e non deve essere usato direttamente dal codice.

(Ereditato da XpsResource)

Si applica a

Prodotto Versioni
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Vedi anche