public static float ConvertFromBits(int bits) { var inst = new FloatToInt(); inst.i = bits; return(inst.f); }
protected override Constant DoSlice(DataType dt, int offset) { var bits = (uint)FloatToInt.ConvertToBits(this.value); var mask = Bits.Mask(0, dt.BitSize); return(Constant.Create(dt, bits >> offset)); }
public static int ConvertToBits(float value) { var inst = new FloatToInt(); inst.f = value; return(inst.i); }
/// <summary> /// 읽기 - double /// </summary> /// <returns>값</returns> public double ReadDouble() { double value = 0; long valueLong = ReadInt64(); if (_error) { return(value); } return(FloatToInt.ToDouble(valueLong)); }
/// <summary> /// 읽기 - float /// </summary> /// <returns>값</returns> public float ReadSingle() { float value = 0; int valueInt = ReadInt32(); if (_error) { return(value); } return(FloatToInt.ToSingle(valueInt)); }
public void Must_not_be_equal() { var value1 = new FloatToInt(0f); var value2 = new FloatToInt((0f * 1f) + 0.00001f); Assert.That(value1 == value2, Is.False); value1 = new FloatToInt(3f * 4f); value2 = new FloatToInt((2f * 6f) + 0.00001f); Assert.That(value1 == value2, Is.False); }
public void Must_be_equal() { var value1 = new FloatToInt(0f); var value2 = new FloatToInt(0f * 1f); Assert.That(value1 == value2, Is.True); value1 = new FloatToInt(3f * 4f); value2 = new FloatToInt(2f * 6f); Assert.That(value1 == value2, Is.True); }
/// <summary> /// This method converts the image to an array. /// </summary> private FloatToInt[] ConvertImagetoArray(Bitmap bitmap) { //Creates floattoint array with image size FloatToInt[] bmvals = new FloatToInt[bitmap.Width * bitmap.Height]; //Converts bitmap image to array int index = 0; for (int h = 0; h < bitmap.Height; h++) { for (int w = 0; w < bitmap.Width; w++) { bmvals[index].IntVal = bitmap.GetPixel(w, h).ToArgb(); index++; } } return(bmvals); }
/// <summary> /// Unpacks a Vertex Normal from: Bo2 /// </summary> /// <param name="packedNormal">Packed 4 byte Vertex Normal</param> /// <returns>Resulting Vertex Normal</returns> public static Vector3 MethodC(PackedUnitVector packedNormal) { // Resulting values var builtX = new FloatToInt { Integer = (uint)((packedNormal.Value & 0x3FF) - 2 * (packedNormal.Value & 0x200) + 0x40400000) }; var builtY = new FloatToInt { Integer = (uint)((((packedNormal.Value >> 10) & 0x3FF) - 2 * ((packedNormal.Value >> 10) & 0x200) + 0x40400000)) }; var builtZ = new FloatToInt { Integer = (uint)((((packedNormal.Value >> 20) & 0x3FF) - 2 * ((packedNormal.Value >> 20) & 0x200) + 0x40400000)) }; // Return decoded vector return(new Vector3( (builtX.Float - 3.0) * 8208.0312f, (builtY.Float - 3.0) * 8208.0312f, (builtZ.Float - 3.0) * 8208.0312f)); }
private void RenderScrollArrows(RendererParameters parameters) { WindowTexture windowTexture = parameters.TextureContent.Windows.InnerBevel1; int x = Window.AbsoluteClientRectangle.Right - windowTexture.SpriteWidth; var scrollPosition = new FloatToInt(_state.ScrollPosition); var upArrowPosition = new Vector2(x, Window.AbsoluteClientRectangle.Y); var downArrowPosition = new Vector2(x, Window.AbsoluteClientRectangle.Bottom - windowTexture.SpriteHeight); Color upArrowColor = (scrollPosition == 0 ? TextAdventure.Xna.Constants.MessageRenderer.DisabledArrowColor : TextAdventure.Xna.Constants.MessageRenderer.ArrowColor) * Alpha; Color downArrowColor = (scrollPosition.FloatValue >= _state.MaximumScrollPosition ? TextAdventure.Xna.Constants.MessageRenderer.DisabledArrowColor : TextAdventure.Xna.Constants.MessageRenderer.ArrowColor) * Alpha; parameters.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone); parameters.SpriteBatch.Draw(windowTexture.Texture, upArrowPosition, windowTexture.UpArrowRectangle, upArrowColor); parameters.SpriteBatch.Draw(windowTexture.Texture, downArrowPosition, windowTexture.DownArrowRectangle, downArrowColor); parameters.SpriteBatch.End(); }
/// <summary> /// Applies the filters to an image in the order the list. /// </summary> private void ApplyFilters(String filterType) { // Create temporary filename and current image to its original String temp = filename + "_temp"; imgPhoto.Source = originalImage; int filterCount = numFilters + 1; for (int i = 1; i < filterCount; i++) { // Save temporary file that function can keep referring to var encoder = new JpegBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create((BitmapSource)imgPhoto.Source)); FileStream stream = new FileStream(temp, FileMode.Create); encoder.Save(stream); stream.Close(); //Converts image to bitmap Bitmap bitmap = new Bitmap(temp); FloatToInt[] bmvals = ConvertImagetoArray(bitmap); //Creates floattoint array for filter output FloatToInt[] output = new FloatToInt[bmvals.Length]; RunFilter(filtersList["Filter" + i].effect, filtersList["Filter" + i].param, ref bmvals, ref output, bmvals.Length); bmvals = output; BitmapImage image = ConvertArraytoImage(bmvals, bitmap); bitmap.Dispose(); //Sets filtered image to source image imgPhoto.Source = image; if (!filterType.Equals("")) { StatusText.Content = "Applied the " + filterType + " filter. "; } } File.Delete(temp); }
public void WriteDouble(double value) { long valueLong = FloatToInt.ToLong(value); WriteInt64(valueLong); }
public void WriteSingle(float value) { int valueInt = FloatToInt.ToInt(value); WriteInt32(valueInt); }
public static ConstantReal32 CreateFromBits(DataType dt, int bits) { var value = FloatToInt.ConvertFromBits(bits); return(new ConstantReal32(dt, value)); }