Last active
August 29, 2015 14:02
-
-
Save michelc/766f95a23ff0931ca8f9 to your computer and use it in GitHub Desktop.
Agrandissement des icones météo en remplaçant chaque pixel par un carré de 4 pixels de même couleur.
This file contains 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
using System.Drawing; | |
using System.Drawing.Imaging; | |
namespace PixelX2 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
for (int w = 0; w < 48; w++) | |
{ | |
Loop(w); | |
} | |
} | |
static void Loop(int weather) | |
{ | |
var icon_gif = string.Format(@"C:\MVC\Pif\Pif\Content\img\meteo2\{0}.gif", weather); | |
var image = Image.FromFile(icon_gif); | |
var width = image.Width; | |
var height = image.Height; | |
var from_55_45 = new Bitmap(image, width, height); | |
var to_110_90 = new Bitmap(width * 2, height * 2); | |
for (var x = 0; x < width; x++) | |
{ | |
for (var y = 0; y < height; y++) | |
{ | |
var c = from_55_45.GetPixel(x, y); | |
var dx = x * 2; | |
var dy = y * 2; | |
to_110_90.SetPixel(dx, dy, c); | |
to_110_90.SetPixel(dx, dy + 1, c); | |
to_110_90.SetPixel(dx + 1, dy, c); | |
to_110_90.SetPixel(dx + 1, dy + 1, c); | |
} | |
} | |
from_55_45.Dispose(); | |
image.Dispose(); | |
var icon_png = string.Format(@"C:\MVC\Pif\Pif\Content\img\meteo3\{0}.png", weather); | |
to_110_90.Save(icon_png, ImageFormat.Png); | |
to_110_90.Dispose(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment