public void TestCreateRetailOrder() { OrderCreateInfo orderCreateInfo = new OrderCreateInfo(); orderCreateInfo.MchOrderId = String.Format("ORDER{0}", DateTime.Now.Ticks); orderCreateInfo.Title = "付款码下单订单"; orderCreateInfo.Price = 12300; orderCreateInfo.Expire = "10m"; string authCode = "284896288107264920"; string deviceId = "111"; ChannelOrder channelOrder = geekChannelOrderFactory.RetailOrder(); OrderInfo orderInfo = channelOrder.Create(orderCreateInfo, authCode, deviceId); Assert.NotEmpty(orderInfo.MchSerialNo); Assert.NotEmpty(orderInfo.OrderId); Assert.Equal(orderCreateInfo.MchOrderId, orderInfo.MchOrderId); Assert.Equal(orderCreateInfo.Price, orderInfo.Price); Assert.Equal(0, orderInfo.MchDiscount); Assert.Equal(0, orderInfo.PlatformDiscount); Assert.True(orderInfo.TotalAmount > 0); Assert.True(orderInfo.PayAmount > 0); Assert.True(orderInfo.ToSettleAmount > 0); Assert.NotEmpty(orderInfo.Channel); Assert.NotEmpty(orderInfo.CreateTime); Assert.NotEmpty(orderInfo.PayTime); Assert.NotEmpty(orderInfo.OrderStatus); Console.WriteLine(JsonConvert.SerializeObject(orderInfo)); }
public override int GetHashCode() { var hashCode = -383231296; hashCode = hashCode * -1521134295 + ChannelOrder.GetHashCode(); hashCode = hashCode * -1521134295 + ChannelDataType.GetHashCode(); return(hashCode); }
/// <summary> /// Convenience function. Checks if a context supports a specific image format /// </summary> /// <param name="flags"></param> /// <param name="type"></param> /// <param name="channelOrder"></param> /// <param name="channelType"></param> /// <returns>true if the image format is supported, false otherwise</returns> public bool SupportsImageFormat(MemFlags flags, MemObjectType type, ChannelOrder channelOrder, ChannelType channelType) { CLImageFormat[] imageFormats = GetSupportedImageFormats(flags, type); foreach (CLImageFormat imageFormat in imageFormats) { if (imageFormat.ChannelOrder == channelOrder && imageFormat.ChannelType == channelType) { return(true); } } return(false); }
/// <summary> /// Convenience function. Checks if a context supports a specific image format /// </summary> /// <param name="flags"></param> /// <param name="type"></param> /// <param name="channelOrder"></param> /// <param name="channelType"></param> /// <returns>true if the image format is supported, false otherwise</returns> public Boolean SupportsImageFormat(MemFlags flags, MemObjectType type, ChannelOrder channelOrder, ChannelType channelType) { var imageFormats = this.GetSupportedImageFormats(flags, type); foreach (var imageFormat in imageFormats) { if (imageFormat.ChannelOrder == channelOrder && imageFormat.ChannelType == channelType) { return(true); } } return(false); }
public float[] EulerToQuat(float x, float y, float z, ChannelOrder RotOrder) { float[] RotMatrix = new float[9]; float XR, YR, ZR; float[] fData = new float[4] { 0.0f, 0.0f, 0.0f, 1.0f }; /*X,Y,Z,W*/ switch (RotOrder) { case ChannelOrder.ZXY: { XR = x / 180.0f * (float)Math.PI; YR = y / 180.0f * (float)Math.PI; ZR = z / 180.0f * (float)Math.PI; float SX = (float)Math.Sin(XR); float CX = (float)Math.Cos(XR); float SY = (float)Math.Sin(YR); float CY = (float)Math.Cos(YR); float SZ = (float)Math.Sin(ZR); float CZ = (float)Math.Cos(ZR); RotMatrix[0] = CY * CZ - SX * SY * SZ; RotMatrix[1] = -CX * SZ; RotMatrix[2] = CZ * SY + CY * SX * SZ; RotMatrix[3] = CZ * SX * SY + CY * SZ; RotMatrix[4] = CX * CZ; RotMatrix[5] = SY * SZ - CY * CZ * SX; RotMatrix[6] = -CX * SY; RotMatrix[7] = SX; RotMatrix[8] = CX * CY; break; } default: break; } fData[0] = 0; fData[1] = 0; fData[2] = 0; fData[3] = 1; fData = rotation2quat(RotMatrix); return(fData); }
private OrderInfo CreateOrder() { GeekChannelOrderFactory geekChannelOrderFactory = new GeekChannelOrderFactory(); OrderCreateInfo orderCreateInfo = new OrderCreateInfo(); orderCreateInfo.MchOrderId = string.Format("ORDER{0}", DateTime.Now.Ticks); orderCreateInfo.Title = "付款码下单订单"; orderCreateInfo.Price = 12300; orderCreateInfo.Expire = "10m"; string authCode = "284896288107264920"; string deviceId = "111"; ChannelOrder channelOrder = geekChannelOrderFactory.RetailOrder(); return(channelOrder.Create(orderCreateInfo, authCode, deviceId)); }
public static Color PSX5551ToColor(int pixel, ChannelOrder order = ChannelOrder.BGR, bool useTransparency = false) { int alpha = 255; int special = (pixel & 0x8000) >> 15; int r = ((pixel & 0x7c00) >> 10) << 3; int g = ((pixel & 0x03e0) >> 5) << 3; int b = (pixel & 0x001f) << 3; if (useTransparency && r == 0 && g == 0 && b == 0) { alpha = 0; } if (order == ChannelOrder.BGR) { int x = r; r = b; b = x; } return(Color.FromArgb(alpha, r, g, b)); }
/// <summary> /// Convenience function. Checks if a context supports a specific image format /// </summary> /// <param name="flags"></param> /// <param name="type"></param> /// <param name="channelOrder"></param> /// <param name="channelType"></param> /// <returns>true if the image format is supported, false otherwise</returns> public bool SupportsImageFormat(MemFlags flags, MemObjectType type, ChannelOrder channelOrder, ChannelType channelType) { ImageFormat[] imageFormats = GetSupportedImageFormats(flags, type); foreach (ImageFormat imageFormat in imageFormats) { if (imageFormat.ChannelOrder == channelOrder && imageFormat.ChannelType == channelType) return true; } return false; }
public Image(Context context, MemoryFlags flags, ChannelOrder order, ChannelType type, ImageType imageType, ulong width, ulong height, ulong depth, ulong arraySize, ulong rowPitch, ulong slicePitch, IntPtr hostPtr) : this() { if (context == Context.Null) { throw new ArgumentNullException("context"); } if (flags.HasFlag(MemoryFlags.WriteOnly) & flags.HasFlag(MemoryFlags.ReadOnly)) { throw new ArgumentException("MemoryFlags.WriteOnly and MemoryFlags.ReadOnly are mutually exclusive."); } if (flags.HasFlag(MemoryFlags.HostWriteOnly) & flags.HasFlag(MemoryFlags.HostReadOnly)) { throw new ArgumentException("MemoryFlags.HostWriteOnly and MemoryFlags.HostReadOnly are mutually exclusive."); } if (flags.HasFlag(MemoryFlags.HostWriteOnly) & flags.HasFlag(MemoryFlags.HostNoAccess)) { throw new ArgumentException("MemoryFlags.HostWriteOnly and MemoryFlags.HostNoAccess are mutually exclusive."); } if (flags.HasFlag(MemoryFlags.HostReadOnly) & flags.HasFlag(MemoryFlags.HostNoAccess)) { throw new ArgumentException("MemoryFlags.HostReadOnly and MemoryFlags.HostNoAccess are mutually exclusive."); } if (width == 0) { throw new ArgumentOutOfRangeException("width", width, "width is 0."); } if (height == 0) { throw new ArgumentOutOfRangeException("height", height, "height is 0."); } if (depth == 0) { throw new ArgumentOutOfRangeException("depth", depth, "depth is 0."); } if (hostPtr == IntPtr.Zero) { if (flags.HasFlag(MemoryFlags.UseHostPtr)) { throw new ArgumentException("MemoryFlags.UseHostPtr is not valid."); } if (flags.HasFlag(MemoryFlags.CopyHostPtr)) { throw new ArgumentException("MemoryFlags.CopyHostPtr is not valid."); } if (rowPitch != 0) { throw new ArgumentOutOfRangeException("rowPitch", rowPitch, "rowPitch is not 0."); } if (slicePitch != 0) { throw new ArgumentOutOfRangeException("slicePitch", slicePitch, "slicePitch is not 0."); } } else { if (!flags.HasFlag(MemoryFlags.UseHostPtr) & !flags.HasFlag(MemoryFlags.CopyHostPtr)) { throw new ArgumentException("MemoryFlags.UseHostPtr or MemoryFlags.CopyHostPtr is required."); } if (flags.HasFlag(MemoryFlags.UseHostPtr) & flags.HasFlag(MemoryFlags.CopyHostPtr)) { throw new ArgumentException("MemoryFlags.UseHostPtr and MemoryFlags.CopyHostPtr are mutually exclusive."); } if (flags.HasFlag(MemoryFlags.UseHostPtr) & flags.HasFlag(MemoryFlags.AllocHostPtr)) { throw new ArgumentException("MemoryFlags.UseHostPtr and MemoryFlags.AllocHostPtr are mutually exclusive."); } if (rowPitch != 0 && rowPitch < width) { throw new ArgumentOutOfRangeException("rowPitch", rowPitch, "rowPitch is not 0 and is less than width."); } if (slicePitch != 0 && slicePitch < height) { throw new ArgumentOutOfRangeException("slicePitch", slicePitch, "slicePitch is not 0 and is less than height."); } } unsafe { Cl.image_format image_format = new Cl.image_format() { image_channel_order = (uint)order, image_channel_data_type = (uint)type, }; Cl.image_desc image_desc = new Cl.image_desc() { image_type = (uint)imageType, image_width = new UIntPtr(width), image_height = new UIntPtr(height), image_depth = new UIntPtr(depth), image_array_size = new UIntPtr(arraySize), image_row_pitch = new UIntPtr(rowPitch), image_slice_pitch = new UIntPtr(slicePitch), num_mip_level = 0, num_samples = 0, buffer = IntPtr.Zero, }; int error; Handle = Cl.CreateImage( context.Handle, (ulong)flags, &image_format, &image_desc, hostPtr.ToPointer(), &error); ClHelper.GetError(error); } }
public static Image CreateImage3D(Context context, MemoryFlags flags, ChannelOrder order, ChannelType type, ulong width, ulong height, ulong depth, ulong rowPitch, ulong slicePitch, IntPtr hostPtr) { if (context == Context.Null) { throw new ArgumentNullException("context"); } if (flags.HasFlag(MemoryFlags.WriteOnly) & flags.HasFlag(MemoryFlags.ReadOnly)) { throw new ArgumentException("MemoryFlags.WriteOnly and MemoryFlags.ReadOnly are mutually exclusive."); } if (flags.HasFlag(MemoryFlags.HostWriteOnly) & flags.HasFlag(MemoryFlags.HostReadOnly)) { throw new ArgumentException("MemoryFlags.HostWriteOnly and MemoryFlags.HostReadOnly are mutually exclusive."); } if (flags.HasFlag(MemoryFlags.HostWriteOnly) & flags.HasFlag(MemoryFlags.HostNoAccess)) { throw new ArgumentException("MemoryFlags.HostWriteOnly and MemoryFlags.HostNoAccess are mutually exclusive."); } if (flags.HasFlag(MemoryFlags.HostReadOnly) & flags.HasFlag(MemoryFlags.HostNoAccess)) { throw new ArgumentException("MemoryFlags.HostReadOnly and MemoryFlags.HostNoAccess are mutually exclusive."); } if (width == 0) { throw new ArgumentOutOfRangeException("width", width, "width is 0."); } if (height == 0) { throw new ArgumentOutOfRangeException("height", height, "height is 0."); } if (depth == 0) { throw new ArgumentOutOfRangeException("depth", depth, "depth is 0."); } if (hostPtr == IntPtr.Zero) { if (flags.HasFlag(MemoryFlags.UseHostPtr)) { throw new ArgumentException("MemoryFlags.UseHostPtr is not valid."); } if (flags.HasFlag(MemoryFlags.CopyHostPtr)) { throw new ArgumentException("MemoryFlags.CopyHostPtr is not valid."); } if (rowPitch != 0) { throw new ArgumentOutOfRangeException("rowPitch", rowPitch, "rowPitch is not 0."); } if (slicePitch != 0) { throw new ArgumentOutOfRangeException("slicePitch", slicePitch, "slicePitch is not 0."); } } else { if (!flags.HasFlag(MemoryFlags.UseHostPtr) & !flags.HasFlag(MemoryFlags.CopyHostPtr)) { throw new ArgumentException("MemoryFlags.UseHostPtr or MemoryFlags.CopyHostPtr is required."); } if (flags.HasFlag(MemoryFlags.UseHostPtr) & flags.HasFlag(MemoryFlags.CopyHostPtr)) { throw new ArgumentException("MemoryFlags.UseHostPtr and MemoryFlags.CopyHostPtr are mutually exclusive."); } if (flags.HasFlag(MemoryFlags.UseHostPtr) & flags.HasFlag(MemoryFlags.AllocHostPtr)) { throw new ArgumentException("MemoryFlags.UseHostPtr and MemoryFlags.AllocHostPtr are mutually exclusive."); } if (rowPitch != 0 && rowPitch < width) { throw new ArgumentOutOfRangeException("rowPitch", rowPitch, "rowPitch is not 0 and is less than width."); } if (slicePitch != 0 && slicePitch < height) { throw new ArgumentOutOfRangeException("slicePitch", slicePitch, "slicePitch is not 0 and is less than height."); } } unsafe { Cl.image_format image_format = new Cl.image_format() { image_channel_order = (uint)order, image_channel_data_type = (uint)type, }; int error; var handle = Cl.CreateImage3D( context.Handle, (ulong)flags, &image_format, new UIntPtr(width), new UIntPtr(height), new UIntPtr(depth), new UIntPtr(rowPitch), new UIntPtr(slicePitch), hostPtr.ToPointer(), &error); ClHelper.GetError(error); return(new Image(handle)); } }
public ImageFormat(ChannelOrder channelOrder, ChannelType channelType) { image_channel_order = (cl_channel_order)channelOrder; image_channel_data_type = (cl_channel_type)channelType; }
public ImageFormat(ChannelOrder channelOrder, ChannelType channelType) { _channelOrder = channelOrder; _channelType = channelType; }
public ImageFormat(ChannelOrder channelOrder, ChannelType channelType) { _channelOrder = channelOrder; _channelType = channelType; }
public ImageFormat(ChannelOrder channelOrder, ChannelType channelDataType) { ChannelOrder = channelOrder; ChannelDataType = channelDataType; }
public ImageFormat(ChannelOrder channelOrder, ChannelType channelType) { this.image_channel_order = (cl_channel_order)channelOrder; this.image_channel_data_type = (cl_channel_type)channelType; }
public CLImageFormat(ChannelOrder order, ChannelType type) { ImageChannelOrder = order; ImageChannelDataType = type; }
public ImageFormat(ChannelOrder order, ChannelType type) { this.ChannelOrder = order; this.ChannelType = type; }