public static ThumbData ReadFromFile(string path) { if (!System.IO.File.Exists(path)) { throw new System.ApplicationException("ファイルが存在していません。"); } ThumbData ret = new ThumbData(); Bitmap bmp = new Bitmap(path); ret.width = bmp.Width; ret.height = bmp.Height; ret.aspect = ret.width / (float)ret.height; Bitmap thumb = new Bitmap(bmp.GetThumbnailImage(WIDTH, HEIGHT, delegate(){ return(true); }, System.IntPtr.Zero)); Img::BitmapData bmpdat = thumb.LockBits(rect88, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); long * d = (long *)ret.px; long * M = (long *)(ret.px + PIXELS); long * s = (long *)bmpdat.Scan0; while (d < M) { *d++ = *s++; } thumb.UnlockBits(bmpdat); thumb.Dispose(); bmp.Dispose(); return(ret); }
public Bitmap GetThumbnailImage() { Bitmap ret = new Bitmap(WIDTH, HEIGHT, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Img::BitmapData data = ret.LockBits(rect88, Img::ImageLockMode.WriteOnly, Img::PixelFormat.Format32bppArgb); // CHECK: data.Stride は 8*4 等でないと困る fixed(int *b = this.px) { long *d = (long *)data.Scan0; long *s = (long *)b; long *M = (long *)(b + PIXELS); while (s < M) { *d++ = *s++; } } ret.UnlockBits(data); return(ret); }