/// <summary> /// 获取图像编码解码器 /// </summary> /// <param name="format">图像文件格式</param> /// <returns>图像编码解码器</returns> private unsafe static ImageCodecInfo getImageCodec(ImageFormat format) { if (format != null) { TmphGuid guid = new TmphGuid { Value = format.Guid }; return imageCodecs.Get(&guid, 16); } return null; }
unsafe static TmphThumbnail() { (qualityEncoder = new EncoderParameters(1)).Param[0] = new EncoderParameter(Encoder.Quality, 100L); ImageCodecInfo[] infos = ImageCodecInfo.GetImageDecoders(); imageCodecs = new CLB.TmphStateSearcher.TmphByteArray<ImageCodecInfo>(infos.getArray(value => CLB.TmphGuid.ToByteArray(value.FormatID)), infos); TmphGuid guid = new TmphGuid { Value = ImageFormat.Jpeg.Guid }; jpegImageCodecInfo = imageCodecs.Get(&guid, 16); }
public static unsafe void ToString(Guid value, TmphCharStream jsonStream) { var guid = new TmphGuid { Value = value }; jsonStream.PrepLength(38); var data = (byte*)jsonStream.CurrentChar; int high = guid.Byte3 >> 4, low = guid.Byte3 & 15; *(char*)data = Quote; *(char*)(data + sizeof(char)) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 2) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); high = guid.Byte2 >> 4; low = guid.Byte2 & 15; *(char*)(data + sizeof(char) * 3) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 4) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); high = guid.Byte1 >> 4; low = guid.Byte1 & 15; *(char*)(data + sizeof(char) * 5) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 6) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); high = guid.Byte0 >> 4; low = guid.Byte0 & 15; *(char*)(data + sizeof(char) * 7) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 8) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 9) = '-'; high = guid.Byte5 >> 4; low = guid.Byte5 & 15; *(char*)(data + sizeof(char) * 10) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 11) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); high = guid.Byte4 >> 4; low = guid.Byte4 & 15; *(char*)(data + sizeof(char) * 12) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 13) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 14) = '-'; high = guid.Byte7 >> 4; low = guid.Byte7 & 15; *(char*)(data + sizeof(char) * 15) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 16) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); high = guid.Byte6 >> 4; low = guid.Byte6 & 15; *(char*)(data + sizeof(char) * 17) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 18) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 19) = '-'; high = guid.Byte8 >> 4; low = guid.Byte8 & 15; *(char*)(data + sizeof(char) * 20) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 21) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); high = guid.Byte9 >> 4; low = guid.Byte9 & 15; *(char*)(data + sizeof(char) * 22) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 23) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 24) = '-'; high = guid.Byte10 >> 4; low = guid.Byte10 & 15; *(char*)(data + sizeof(char) * 25) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 26) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); high = guid.Byte11 >> 4; low = guid.Byte11 & 15; *(char*)(data + sizeof(char) * 27) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 28) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); high = guid.Byte12 >> 4; low = guid.Byte12 & 15; *(char*)(data + sizeof(char) * 29) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 30) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); high = guid.Byte13 >> 4; low = guid.Byte13 & 15; *(char*)(data + sizeof(char) * 31) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 32) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); high = guid.Byte14 >> 4; low = guid.Byte14 & 15; *(char*)(data + sizeof(char) * 33) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 34) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); high = guid.Byte15 >> 4; low = guid.Byte15 & 15; *(char*)(data + sizeof(char) * 35) = (char)(high < 10 ? high + '0' : (high + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 36) = (char)(low < 10 ? low + '0' : (low + ('0' + 'A' - '9' - 1))); *(char*)(data + sizeof(char) * 37) = Quote; jsonStream.Unsafer.AddLength(38); }