kujikita

BitmapExtensions.cs

Feb 22nd, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.97 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace KKtImgLib
  8. {
  9.     static class BitmapExtensions
  10.     {
  11.         public const float _4bit = 255 / 15f;
  12.         public const float _5bit = 255 / 31f;
  13.         public const float _6bit = 255 / 63f;
  14.  
  15.         public static Bitmap.R8G8B8A8[] ToR8G8B8A8(this Bitmap.R8[] R)
  16.         {
  17.             Bitmap.R8G8B8A8[] RGBA = new Bitmap.R8G8B8A8[16];
  18.             for (byte i = 0; i < 16; i++) RGBA[i] = new Bitmap.R8G8B8A8(R[i].R, 0, 0, 0xFF);
  19.             return RGBA;
  20.         }
  21.  
  22.         public static Bitmap.R8G8B8A8[] ToR8G8B8A8(this Bitmap.R8G8[] RG)
  23.         {
  24.             Bitmap.R8G8B8A8[] RGB = new Bitmap.R8G8B8A8[16];
  25.             for (byte i = 0; i < 16; i++) RGB[i] = new Bitmap.R8G8B8A8(RG[i].R, RG[i].G, 0, 0xFF);
  26.             return RGB;
  27.         }
  28.  
  29.         public static Bitmap.R8G8B8A8[] ToR8G8B8A8(this Bitmap.R8G8B8[] RGB)
  30.         {
  31.             Bitmap.R8G8B8A8[] RGBA = new Bitmap.R8G8B8A8[16];
  32.             for (byte i = 0; i < 16; i++) RGBA[i] = (Bitmap.R8G8B8A8)RGB[i];
  33.             return RGBA;
  34.         }
  35.  
  36.         public static Bitmap.R8G8B8[] ToR8G8B8(this Bitmap.R8G8B8A8[] RGBA)
  37.         {
  38.             Bitmap.R8G8B8[] RGB = new Bitmap.R8G8B8[16];
  39.             for (byte i = 0; i < 16; i++) RGB[i] = (Bitmap.R8G8B8)RGBA[i];
  40.             return RGB;
  41.         }
  42.  
  43.         public static Bitmap.R16G16B16A16[] ToR16G16B16A16(this Bitmap.R8G8B8A8[] RGBA)
  44.         {
  45.             Bitmap.R16G16B16A16[] RGBA16 = new Bitmap.R16G16B16A16[16];
  46.             for (byte i = 0; i < 16; i++) RGBA16[i] = (Bitmap.R16G16B16A16)RGBA[i];
  47.             return RGBA16;
  48.         }
  49.  
  50.         public static Bitmap.R16G16B16[] ToR16G16B16(this Bitmap.R8G8B8A8[] RGBA)
  51.         {
  52.             Bitmap.R16G16B16[] RGB = new Bitmap.R16G16B16[16];
  53.             for (byte i = 0; i < 16; i++) RGB[i] = (Bitmap.R16G16B16)(Bitmap.R8G8B8)RGBA[i];
  54.             return RGB;
  55.         }
  56.     }
  57. }
Add Comment
Please, Sign In to add comment