Extensions/ImageGlass.Core/Interpreter.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
namespace ImageGlass.Core
{
public class Interpreter
{
public static Bitmap load(string path)
{
if (path.ToLower().EndsWith(".tga")) return Targa(path);
return new Bitmap(path);
}
// Tested on files created by:
// - photoshop
// - mspaint
// - TF2
public static Bitmap Targa(string path)
{
byte[] src = System.IO.File.ReadAllBytes(path);
int w = src[0x0D] * 256 + src[0x0C];
int h = src[0x0F] * 256 + src[0x0E];
bool flip = src[0x11] == 0x20;
Bitmap bm = new Bitmap(w, h);
BitmapData bd = bm.LockBits(new Rectangle(0, 0, w, h),
System.Drawing.Imaging.ImageLockMode.WriteOnly,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
int sp;
unsafe
{
for (int y = 0; y < h; y++)
{
if (flip) sp = 0x12 + 3 * w * y;
else sp = 0x12 + 3 * w * (h - y - 1);
byte* dst = (byte*)bd.Scan0 + (bd.Stride * y);
for (int n = 0; n < 3 * w; n++)
{
dst[n] = src[n + sp];
}
}
}
bm.UnlockBits(bd);
return bm;
}
public static Bitmap TargaWhatTheFuck(string path)
{
byte[] src = System.IO.File.ReadAllBytes(path);
int w = src[0x0D] * 256 + src[0x0C];
int h = src[0x0F] * 256 + src[0x0E];
Bitmap bm = new Bitmap(w, h);
BitmapData bd = bm.LockBits(new Rectangle(0, 0, w, h),
System.Drawing.Imaging.ImageLockMode.WriteOnly,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
unsafe
{
后面还有 18 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。