Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/targadactyl/src/tga.ts>TgaLoader#decode

tga.js implemented in Deno
Latest
method TgaLoader.prototype.decode
import { TgaLoader } from "https://deno.land/x/targadactyl@1.2.0/src/tga.ts";

Helper method for decoding the TGA file as an Uint8Array. Useful for serving the image.

Examples

Example 1

 const tga = new TgaLoader();
 const contentType = "image/png";
 const res = new Response(
   tga.load(await tga.open("./test.tga")).decode(contentType),
   {
     status: 200,
     headers: {
      "Content-Type": contentType
     }
   }
 );

 // Now serve it!

Parameters

contentType: "image/png" | "image/jpeg"

Specify the MIME type to use in decoding and serving

Returns

Uint8Array

.tga data decoded in the specified MIME type