public GlyphBitmap(FTBitmap bitmap) { Pitch = bitmap.Pitch; Rows = bitmap.Rows; Width = bitmap.Width; PixelMode = bitmap.PixelMode; BufferData = Pitch == 0 ? new byte[0] : bitmap.BufferData; }
public void Begin(SortMode sortMode = SortMode.Deferred, PixelMode colorMode = PixelMode.Normal, Shader shader = null, Transform transform = null) { if (hasBegun) { throw new Exception("A SpriteBatch has already begun."); } hasBegun = true; this.sortMode = sortMode; this.colorMode = colorMode; this.shader = shader; this.transform = transform == null ? new Transform() : transform; }
public void End() { hasBegun = false; if (batchItemCount == 0) { return; } int indexStart = 0; switch (sortMode) { case SortMode.BackToFront: Array.Sort(batchItemList, 0, batchItemCount); break; case SortMode.FrontToBack: Array.Sort(batchItemList, 0, batchItemCount); Array.Reverse(batchItemList); indexStart = batchItemCapacity - batchItemCount; break; } for (int i = indexStart; i < indexStart + batchItemCount; i++) { SpriteBatchItem item = batchItemList[i]; PixelMode oldMode = game.PixelMode; game.PixelMode = colorMode; Transform newTransform = transform.Copy(); if (item.Scale.X != 1 && item.Scale.Y != 1) { newTransform.Scale(item.Scale.X, item.Scale.Y); } if (item.Rotation != 0) { newTransform.Rotate(item.Rotation); } newTransform.Translate(item.Position.X, item.Position.Y); Transform.DrawSprite(item.Sprite, newTransform, item.Color); game.PixelMode = oldMode; } batchItemCount = 0; }
/// <summary> /// Initializes a new instance of the <see cref="CharacterBitmap"/> class from a data array. /// </summary> /// <param name="pixelMode">The data format of the bitmap data</param> /// <param name="data">The bitmap data</param> /// <param name="borderSize">The size of the border around the image</param> /// <param name="width">The width of the bitmap </param> /// <param name="rows">The height of the bitmap</param> /// <param name="pitch">The pitch of the bitmap</param> /// <param name="grayLevels">The number of gray levels of the bitmap</param> public CharacterBitmap(IntPtr data, ref Int2 borderSize, int width, int rows, int pitch, int grayLevels, PixelMode pixelMode) { // add one empty border to each side of the bitmap width += 2 * borderSize.X; rows += 2 * borderSize.Y; buffer = Utilities.AllocateMemory(width * rows, 1); if (pixelMode == PixelMode.Mono) CopyAndAddBordersFromMono(data, buffer, ref borderSize, width, rows, pitch); else CopyAndAddBordersFromGrays(data, buffer, ref borderSize, width, rows); this.width = width; this.rows = rows; this.pitch = width; this.grayLevels = grayLevels; this.pixelMode = pixelMode; }
/// <summary> /// Initializes a new instance of the <see cref="CharacterBitmap"/> class from a data array. /// </summary> /// <param name="pixelMode">The data format of the bitmap data</param> /// <param name="data">The bitmap data</param> /// <param name="borderSize">The size of the border around the image</param> /// <param name="width">The width of the bitmap </param> /// <param name="rows">The height of the bitmap</param> /// <param name="pitch">The pitch of the bitmap</param> /// <param name="grayLevels">The number of gray levels of the bitmap</param> public CharacterBitmap(IntPtr data, ref Int2 borderSize, int width, int rows, int pitch, int grayLevels, PixelMode pixelMode) { // add one empty border to each side of the bitmap width += 2 * borderSize.X; rows += 2 * borderSize.Y; buffer = Utilities.AllocateMemory(width * rows, 1); if (pixelMode == PixelMode.Mono) { CopyAndAddBordersFromMono(data, buffer, ref borderSize, width, rows, pitch); } else { CopyAndAddBordersFromGrays(data, buffer, ref borderSize, width, rows); } this.width = width; this.rows = rows; this.pitch = width; this.grayLevels = grayLevels; this.pixelMode = pixelMode; }
public Pixel(byte red, byte green, byte blue, byte alpha = nDefaultAlpha) { n = 0; //Hack to fool the complier r = red; g = green; b = blue; a = alpha; Mode = PixelMode.NORMAL; }
public Pixel(int p) { r = 0; g = 0; b = 0; a = 0; //Hack to fool the complier n = p; Mode = PixelMode.NORMAL; }