---
title: "Ändra GIF-format"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/104128-ändra-gif-format"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "m-blo"
published: "2004-05-22T12:16:11.000Z"
updated: "2004-05-24T12:12:29.000Z"
replies: 2
views: 426
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/104128-ändra-gif-format"
---

# Ändra GIF-format

## #1 — m-blo, 2004-05-22T12:16Z

Använder koden nedan för att skicka ett värde i en querystring och sedan skapa en bild med just det värdet (texten) i... Problemet är att jag vill byta GIF-format...  Jag vill byta färgformatet till "Optimized Octree"... Går det att ändra format? Alternativt , går det att ändra kompressionen om man använder JPG istället?

```
<%@ Page Language="VB" Debug="True" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Text" %>
<%
' Declare Vars
Dim objBMP        As System.Drawing.Bitmap
Dim objGraphics   As System.Drawing.Graphics
Dim objFont       As System.Drawing.Font

' Create new image - bitmap
objBMP = New Bitmap(250, 30)

' Create a graphics object to work with from the BMP
objGraphics = System.Drawing.Graphics.FromImage(objBMP)

' Fill the image with background color
objGraphics.Clear(Color.White)

' Set anti-aliasing for text to make it better looking
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias

' Configure font to use for text
objFont = New Font("Verdana", 8, FontStyle.Bold)

' Write out the text
objGraphics.DrawString(Request.QueryString("text"), objFont, Brushes.Black,  3, 3)

' Set the content type and return the image
Response.ContentType = "image/GIF"
objBMP.Save(Response.OutputStream, ImageFormat.Gif)

' Kill our objects
objFont.Dispose()
objGraphics.Dispose()
objBMP.Dispose()
%>
```

Permalänk: https://www.webforum.nu/p/104128

## #2 — fredrik, 2004-05-24T12:04Z

I följande tråd kan du läsa om hur JPG-kompression kan sättas:

<http://www.webforum.nu/showthread.php?s=&forumid=29&threadid=79164&highlight=jpg>

Permalänk: https://www.webforum.nu/p/1353105

## #3 — m-blo, 2004-05-24T12:12Z

Tack.

Permalänk: https://www.webforum.nu/p/1353107

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/104128-ändra-gif-format
