Esempio n. 1
0
 private void rdbWide_CheckedChanged(object sender, EventArgs e)
 {
     if (rdbWide.Checked)
     {
         tileMode = TileMode.Width;
     }
 }
Esempio n. 2
0
 private void rdbVariants_CheckedChanged(object sender, EventArgs e)
 {
     if (rdbVariants.Checked)
     {
         tileMode = TileMode.Variants;
     }
 }
Esempio n. 3
0
 private void rdbScroll2_CheckedChanged(object sender, EventArgs e)
 {
     if (rdbScroll2.Checked)
     {
         tileMode = TileMode.Scrolls;
     }
 }
Esempio n. 4
0
 private void rdbBlocks_CheckedChanged(object sender, EventArgs e)
 {
     if (rdbBlocks.Checked)
     {
         tileMode = TileMode.Blocks;
     }
 }
Esempio n. 5
0
        public static Matrix CalculateIntermediateTransform(
            TileMode tileMode,
            Rect sourceRect,
            Rect destinationRect,
            Vector scale,
            Vector translate,
            out Rect drawRect)
        {
            var transform = Matrix.CreateTranslation(-sourceRect.Position) *
                            Matrix.CreateScale(scale) *
                            Matrix.CreateTranslation(translate);
            Rect dr;

            if (tileMode == TileMode.None)
            {
                dr         = destinationRect;
                transform *= Matrix.CreateTranslation(destinationRect.Position);
            }
            else
            {
                dr = new Rect(destinationRect.Size);
            }

            drawRect = dr;

            return(transform);
        }
Esempio n. 6
0
        protected static Matrix CalculateIntermediateTransform(
            TileMode tileMode,
            Rect sourceRect,
            Rect destinationRect,
            Vector scale,
            Vector translate,
            out Rect drawRect)
        {
            var transform = Matrix.CreateTranslation(-sourceRect.Position) *
                Matrix.CreateScale(scale) *
                Matrix.CreateTranslation(translate);
            Rect dr;

            if (tileMode == TileMode.None)
            {
                dr = destinationRect;
                transform *= Matrix.CreateTranslation(destinationRect.Position);
            }
            else
            {
                dr = new Rect(destinationRect.Size);
            }

            drawRect = dr;

            return transform;
        }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImmutableImageBrush"/> class.
 /// </summary>
 /// <param name="source">The image to draw.</param>
 /// <param name="alignmentX">The horizontal alignment of a tile in the destination.</param>
 /// <param name="alignmentY">The vertical alignment of a tile in the destination.</param>
 /// <param name="destinationRect">The rectangle on the destination in which to paint a tile.</param>
 /// <param name="opacity">The opacity of the brush.</param>
 /// <param name="transform">The transform of the brush.</param>
 /// <param name="transformOrigin">The transform origin of the brush</param>
 /// <param name="sourceRect">The rectangle of the source image that will be displayed.</param>
 /// <param name="stretch">
 /// How the source rectangle will be stretched to fill the destination rect.
 /// </param>
 /// <param name="tileMode">The tile mode.</param>
 /// <param name="bitmapInterpolationMode">The bitmap interpolation mode.</param>
 public ImmutableImageBrush(
     IBitmap source,
     AlignmentX alignmentX        = AlignmentX.Center,
     AlignmentY alignmentY        = AlignmentY.Center,
     RelativeRect?destinationRect = null,
     double opacity = 1,
     ImmutableTransform?transform  = null,
     RelativePoint transformOrigin = new RelativePoint(),
     RelativeRect?sourceRect       = null,
     Stretch stretch   = Stretch.Uniform,
     TileMode tileMode = TileMode.None,
     BitmapInterpolationMode bitmapInterpolationMode = BitmapInterpolationMode.Default)
     : base(
         alignmentX,
         alignmentY,
         destinationRect ?? RelativeRect.Fill,
         opacity,
         transform,
         transformOrigin,
         sourceRect ?? RelativeRect.Fill,
         stretch,
         tileMode,
         bitmapInterpolationMode)
 {
     Source = source;
 }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TileBrushCalculator"/> class.
        /// </summary>
        /// <param name="tileMode">The brush's tile mode.</param>
        /// <param name="stretch">The brush's stretch.</param>
        /// <param name="alignmentX">The brush's horizontal alignment.</param>
        /// <param name="alignmentY">The brush's vertical alignment.</param>
        /// <param name="sourceRect">The brush's source rect</param>
        /// <param name="destinationRect">The brush's destination rect.</param>
        /// <param name="contentSize">The size of the content of the tile brush.</param>
        /// <param name="targetSize">The size of the control to which the brush is being rendered.</param>
        public TileBrushCalculator(
            TileMode tileMode,
            Stretch stretch,
            AlignmentX alignmentX,
            AlignmentY alignmentY,
            RelativeRect sourceRect,
            RelativeRect destinationRect,
            Size contentSize,
            Size targetSize)
        {
            _imageSize = contentSize;

            SourceRect      = sourceRect.ToPixels(_imageSize);
            DestinationRect = destinationRect.ToPixels(targetSize);

            var scale     = stretch.CalculateScaling(DestinationRect.Size, SourceRect.Size);
            var translate = CalculateTranslate(alignmentX, alignmentY, SourceRect, DestinationRect, scale);

            IntermediateSize      = tileMode == TileMode.None ? targetSize : DestinationRect.Size;
            IntermediateTransform = CalculateIntermediateTransform(
                tileMode,
                SourceRect,
                DestinationRect,
                scale,
                translate,
                out _drawRect);
        }
Esempio n. 9
0
 private void Load(Properties props)
 {
     Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
     BackgroundImagesDirectoryAbsolutePath = Setting.ToFullPath((string)props.Item("BackgroundImageDirectoryAbsolutePath").Value, DefaultBackgroundFolder);
     BackgroundImageAbsolutePath           = Setting.ToFullPath((string)props.Item("BackgroundImageAbsolutePath").Value, DefaultBackgroundImage);
     Opacity                     = (double)props.Item("Opacity").Value;
     PositionHorizon             = (PositionH)props.Item("PositionHorizon").Value;
     PositionVertical            = (PositionV)props.Item("PositionVertical").Value;
     ImageStretch                = (ImageStretch)props.Item("ImageStretch").Value;
     UpdateImageInterval         = (TimeSpan)props.Item("UpdateImageInterval").Value;
     Extensions                  = (string)props.Item("Extensions").Value;
     ImageBackgroundType         = (ImageBackgroundType)props.Item("ImageBackgroundType").Value;
     ImageFadeAnimationInterval  = (TimeSpan)props.Item("ImageFadeAnimationInterval").Value;
     LoopSlideshow               = (bool)props.Item("LoopSlideshow").Value;
     ShuffleSlideshow            = (bool)props.Item("ShuffleSlideshow").Value;
     MaxWidth                    = (int)props.Item("MaxWidth").Value;
     MaxHeight                   = (int)props.Item("MaxHeight").Value;
     SoftEdgeX                   = (int)props.Item("SoftEdgeX").Value;
     SoftEdgeY                   = (int)props.Item("SoftEdgeY").Value;
     ExpandToIDE                 = (bool)props.Item("ExpandToIDE").Value;
     ViewBoxPointX               = (double)props.Item("ViewBoxPointX").Value;
     ViewBoxPointY               = (double)props.Item("ViewBoxPointY").Value;
     IsLimitToMainlyEditorWindow = (bool)props.Item("IsLimitToMainlyEditorWindow").Value;
     TileMode                    = (TileMode)props.Item("TileMode").Value;
     ViewPortHeight              = (double)props.Item("ViewPortHeight").Value;
     ViewPortWidth               = (double)props.Item("ViewPortWidth").Value;
     ViewPortPointX              = (double)props.Item("ViewPortPointX").Value;
     ViewPortPointY              = (double)props.Item("ViewPortPointY").Value;
 }
Esempio n. 10
0
        public _SweepGradient(
            Offset center, List <Color> colors,
            List <float> colorStops = null, TileMode tileMode = TileMode.clamp,
            float startAngle        = 0.0f, float endAngle    = Mathf.PI * 2,
            uiMatrix3?matrix        = null
            )
        {
            this.center     = center;
            this.colors     = colors;
            this.colorStops = colorStops;
            this.tileMode   = tileMode;
            this.startAngle = startAngle;
            this.endAngle   = endAngle;
            this.matrix     = matrix;

            var t0 = startAngle / (Mathf.PI * 2f);
            var t1 = endAngle / (Mathf.PI * 2f);

            this.bias  = -t0;
            this.scale = 1f / (t1 - t0);

            var ptsToUnit = uiMatrix3.I();

            ptsToUnit.setTranslate(-center.dx, -center.dy);
            this.ptsToUnit = ptsToUnit;

            this.gradientTex = makeTexturedColorizer(colors, colorStops);
        }
Esempio n. 11
0
        Client Manage( IntPtr hwnd , TileMode tileMode )
        {

            if ( ContainClient( hwnd ) )
            {
                return GetClient( hwnd );
            }
            WindowInfo windowInfo = new WindowInfo( );
            User32Methods.GetWindowInfo( hwnd , ref windowInfo );
            Client client = CreateClient( hwnd );
            if ( tileMode == TileMode.Tile )
            {

                WindowPlacement windowPlacement = new WindowPlacement( );
                if ( User32Methods.IsWindowVisible( client.Hwnd )  )
                {
                    User32Methods.SetWindowPlacement( hwnd , ref windowPlacement );
                }

                if ( User32Methods.IsWindowVisible( client.Hwnd )  )
                {
                    Rectangle windowRect = windowInfo.WindowRect;
                    DWM.resize( client , windowRect.Left , windowRect.Top , windowRect.Width , windowRect.Height , ScreenGeom.Rect );
                }
            }
            client.TileMode = tileMode;

            WindowManager.Attach( client , WindowManager.SelectedTag );
            return client;
        }
Esempio n. 12
0
        public SceneOW(OverworldEditor f, Overworld ow, DungeonMain mform)
        {
            owForm   = f;
            mainForm = mform;
            this.ow  = ow;
            //graphics = Graphics.FromImage(scene_bitmap);
            //this.Image = new Bitmap(4096, 4096);
            this.MouseUp          += new MouseEventHandler(onMouseUp);
            this.MouseMove        += new MouseEventHandler(onMouseMove);
            this.MouseDoubleClick += new MouseEventHandler(onMouseDoubleClick);
            this.MouseWheel       += SceneOW_MouseWheel;
            tilesgfxBitmap         = new Bitmap(512, 512, 512, PixelFormat.Format8bppIndexed, temptilesgfxPtr);
            tilemode       = new TileMode(this);
            exitmode       = new ExitMode(this);
            doorMode       = new DoorMode(this);
            entranceMode   = new EntranceMode(this);
            selectedMode   = ObjectMode.Tile;
            itemMode       = new ItemMode(this);
            spriteMode     = new SpriteMode(this);
            transportMode  = new TransportMode(this);
            overlayMode    = new OverlayMode(this);
            gravestoneMode = new GravestoneMode(this);

            //this.Width = 8192;
            //this.Height = 8192;
            //this.Size = new Size(8192, 8192);
            //this.Refresh();
        }
Esempio n. 13
0
 public void ChangeTileMode(int _tileMode)
 {
     tileMode = (TileMode)_tileMode;
     if (currentTile != null)
     {
         currentTile.SetActive(false);
     }
     if (_tileMode != 0)
     {
         currentTile = tiles[_tileMode - 1];
         currentTile.SetActive(true);
         if ((TileMode)_tileMode == TileMode.NormalWall || (TileMode)_tileMode == TileMode.Mirror || (TileMode)_tileMode == TileMode.Glass ||
             (TileMode)_tileMode == TileMode.LightPole || (TileMode)_tileMode == TileMode.LightGetter)
         {
             isFloat   = true;
             isAtPoint = false;
         }
         else
         {
             isFloat   = false;
             isAtPoint = false;
         }
     }
     else
     {
         currentTile = null;
     }
     PrintDebugText("Tile mode changed to " + (TileMode)_tileMode);
 }
Esempio n. 14
0
 public ImageShader(Image image,
                    TileMode tileMode = TileMode.clamp, uiMatrix3?matrix = null)
 {
     this.image    = image;
     this.tileMode = tileMode;
     this.matrix   = matrix;
 }
Esempio n. 15
0
 public ImageBrushTool(ImageSource i, TileMode m, Rect v, BrushMappingMode u, double o = 1) : this()
 {
     Image = i;
     Mode = m;
     Viewport = v;
     ViewportUnits = u;
     Opacity = o;
 }
Esempio n. 16
0
 protected static Size2F CalculateIntermediateSize(
     TileMode tileMode,
     Size targetSize,
     Size destinationSize)
 {
     var result = tileMode == TileMode.None ? targetSize : destinationSize;
     return result.ToSharpDX();
 }
Esempio n. 17
0
 public ImageBrushTool(ImageSource i, TileMode m, Rect v, BrushMappingMode u, double o = 1) : this()
 {
     Image         = i;
     Mode          = m;
     Viewport      = v;
     ViewportUnits = u;
     Opacity       = o;
 }
Esempio n. 18
0
        public wFillBitmap(Bitmap FillBitmapObject, int BitmapAlignment, int BitmapFillMethod, int TilingMode)
        {
            Alignment  = BitmapAlignment;
            FillMethod = BitmapFillMethod;
            Tiling     = (TileMode)TilingMode;

            BaseBitmap = FillBitmapObject;
            BuildBrush();
        }
Esempio n. 19
0
        private static Size CalculateIntermediateSize(
            TileMode tileMode,
            Size targetSize,
            Size destinationSize)
        {
            var result = tileMode == TileMode.None ? targetSize : destinationSize;

            return(result);
        }
Esempio n. 20
0
 public override void Init()
 {
     InitConfig();
     assetsManager = new AssetsManager();
     uiManager     = new UIManager();
     saveManager   = new SaveManager();
     netManager    = new NetworkManager();
     tileMode      = new TileMode();
 }
Esempio n. 21
0
        protected static Size2F CalculateIntermediateSize(
            TileMode tileMode,
            Size targetSize,
            Size destinationSize)
        {
            var result = tileMode == TileMode.None ? targetSize : destinationSize;

            return(result.ToSharpDX());
        }
Esempio n. 22
0
        /// <summary>
        ///     Returns whether or not an enumeration instance a valid value.
        ///     This method is designed to be used with ValidateValueCallback, and thus
        ///     matches it's prototype.
        /// </summary>
        /// <param name="valueObject">
        ///     Enumeration value to validate.
        /// </param>
        /// <returns> 'true' if the enumeration contains a valid value, 'false' otherwise. </returns>
        public static bool IsTileModeValid(object valueObject)
        {
            TileMode value = (TileMode)valueObject;

            return((value == TileMode.None) ||
                   (value == TileMode.Tile) ||
                   (value == TileMode.FlipX) ||
                   (value == TileMode.FlipY) ||
                   (value == TileMode.FlipXY));
        }
Esempio n. 23
0
        public wFillBitmap(Bitmap FillBitmapObject, int BitmapAlignment, int BitmapFillMethod, int TilingMode, double RotationAngle, double ScaleFactor)
        {
            Alignment  = BitmapAlignment;
            FillMethod = BitmapFillMethod;
            Tiling     = (TileMode)TilingMode;
            Angle      = RotationAngle;
            Scale      = ScaleFactor;

            BaseBitmap = FillBitmapObject;
            BuildBrush();
        }
Esempio n. 24
0
        public void LoadNGCRImageWithNcer(Ebk ebk)
        {
            ColorDepth depth      = Char.IntensidadeDeBits == 3 ? ColorDepth.F4BBP : ColorDepth.F8BBP;
            TypeSprite typeSprite = new TypeSprite()
            {
                Oams = ebk.Oams, TileBoundary = (int)ArquivoNcer.Cebk.TileBoundary
            };
            TileMode tileMode = Char.FlagDeDimensao == 0 ? TileMode.Tiled : TileMode.NotTiled;

            ConvertedImage = ImageConverter.SpriteToBitmap(Char.Tiles, ArquivoNclr.Pltt.Paleta, typeSprite, tileMode, depth);
        }
Esempio n. 25
0
 bool Scan( IntPtr hwnd , IntPtr lParam )
 {
     TileMode tileMode = IsManageable( hwnd );
     if ( tileMode != TileMode.NoHandle )
     {
         Manage( hwnd , tileMode );
         // chrome、最小化してるウィンドウがマスターだとサイズが0のように処理される
         ThreadWindowHandles.ShowWindow( hwnd , ThreadWindowHandles.SW.SW_RESTORE );
     }
     return true;
 }
Esempio n. 26
0
        private SpriteDrawMode Translate(TileMode mode)
        {
            switch (mode)
            {
            case TileMode.Tile: return(SpriteDrawMode.Tiled);

            case TileMode.Stretch: return(SpriteDrawMode.Sliced);

            default: throw new System.ArgumentOutOfRangeException(nameof(mode));
            }
        }
Esempio n. 27
0
 private TextureWrapMode conv(TileMode t)
 {
     return(t switch
     {
         TileMode.ClampToBorder => TextureWrapMode.ClampToBorder,
         TileMode.ClampToEdge => TextureWrapMode.ClampToEdge,
         TileMode.MirrorClampToEdge => (TextureWrapMode)All.MirrorClampToEdge,
         TileMode.MirroredRepeat => TextureWrapMode.MirroredRepeat,
         TileMode.Repeat => TextureWrapMode.Repeat,
         _ => throw new Exception("Unknown TileMode")
     });
Esempio n. 28
0
        public TileBrushImplHelper(TileBrush brush, Size targetSize)
        {
            _imageBrush  = brush as ImageBrush;
            _visualBrush = brush as VisualBrush;
            if (_imageBrush != null)
            {
                if (_imageBrush.Source == null)
                {
                    return;
                }
                _imageSize = new Size(_imageBrush.Source.PixelWidth, _imageBrush.Source.PixelHeight);
                IsValid    = true;
            }
            else if (_visualBrush != null)
            {
                var visual = _visualBrush.Visual;
                if (visual == null)
                {
                    return;
                }
                var layoutable = visual as ILayoutable;

                if (layoutable != null)
                {
                    if (layoutable.IsArrangeValid == false)
                    {
                        layoutable.Measure(Size.Infinity);
                        layoutable.Arrange(new Rect(layoutable.DesiredSize));
                    }

                    _imageSize = layoutable.Bounds.Size;
                    IsValid    = true;
                }
            }
            else
            {
                return;
            }

            _tileMode        = brush.TileMode;
            _sourceRect      = brush.SourceRect.ToPixels(_imageSize);
            DestinationRect  = brush.DestinationRect.ToPixels(targetSize);
            _scale           = brush.Stretch.CalculateScaling(DestinationRect.Size, _sourceRect.Size);
            _translate       = CalculateTranslate(brush, _sourceRect, DestinationRect, _scale);
            IntermediateSize = CalculateIntermediateSize(_tileMode, targetSize, DestinationRect.Size);
            _transform       = CalculateIntermediateTransform(
                _tileMode,
                _sourceRect,
                DestinationRect,
                _scale,
                _translate,
                out _drawRect);
        }
Esempio n. 29
0
        /// <summary>
        /// Creates a texture from a filepath with specified tile mode and viewport
        /// </summary>
        /// <param name="filepath">Texture filepath</param>
        /// <param name="tileMode">Tile mode of the texture</param>
        /// <param name="viewPort">Viewport of the texture</param>
        public Texture(string filepath, TileMode tileMode, Rect viewport)
        {
            ImageSource    = new BitmapImage(new Uri(filepath, UriKind.RelativeOrAbsolute));
            Brush          = new ImageBrush(ImageSource);
            Brush.TileMode = tileMode;
            Brush.Viewport = viewport;

            Width    = ImageSource.PixelWidth;
            Height   = ImageSource.PixelHeight;
            Name     = filepath.Substring(filepath.LastIndexOf('/') + 1);
            Filepath = filepath;
        }
Esempio n. 30
0
 public RadialGradient(
     Alignment center    = null,
     float radius        = 0.5f,
     List <Color> colors = null,
     List <float> stops  = null,
     TileMode tileMode   = TileMode.clamp
     ) : base(colors: colors, stops: stops)
 {
     this.center   = center ?? Alignment.center;
     this.radius   = radius;
     this.tileMode = tileMode;
 }
Esempio n. 31
0
 public LinearGradient(
     Alignment begin     = null,
     Alignment end       = null,
     List <Color> colors = null,
     List <float> stops  = null,
     TileMode tileMode   = TileMode.clamp
     ) : base(colors: colors, stops: stops)
 {
     this.begin    = begin ?? Alignment.centerLeft;
     this.end      = end ?? Alignment.centerRight;
     this.tileMode = tileMode;
 }
Esempio n. 32
0
 public ClientSetting(
     string windowname,
     string windowclass,
     string tagid,
     TileMode _tilemode
     )
 {
     WindowName  = windowname;
     WindowClass = windowclass;
     TagId       = tagid;
     _TileMode   = _tilemode;
 }
Esempio n. 33
0
        public static Gradient radial(
            Offset center, float radius, List <Color> colors,
            List <float> colorStops = null, TileMode tileMode = TileMode.clamp,
            uiMatrix3?matrix        = null)
        {
            D.assert(PaintingUtils._offsetIsValid(center));
            D.assert(colors != null && colors.Count >= 2);

            _validateColorStops(ref colors, ref colorStops);

            return(new _RadialGradient(center, radius, colors, colorStops, tileMode, matrix));
        }
Esempio n. 34
0
		public void AddImage(string path, TileMode tile = TileMode.None, Rect? targetArea = null, Stretch stretch = Stretch.Fill, Rectangle rect = null, UriKind kind = UriKind.Relative)
		{
			BitmapImage bm = new BitmapImage(new Uri(path, kind));
			UIElement el = null;
			if (tile != TileMode.None && rect == null)
			{
				Rectangle r = new Rectangle();
				if (targetArea.HasValue)
				{
					r.Width = targetArea.Value.Width;
					r.Height = targetArea.Value.Height;
				}
				else
				{
					r.Width = this.ActualWidth;
					r.Height = this.ActualHeight;
				}
				Rect rr = new Rect();
				rr.Width = bm.PixelWidth;
				rr.Height = bm.PixelHeight;
				ImageDrawing d = new ImageDrawing(bm, rr);
				DrawingBrush brush = new DrawingBrush(d);
				brush.Viewport = rr;
				brush.ViewportUnits = BrushMappingMode.Absolute;
				brush.TileMode = tile;
				brush.Stretch = Stretch.Fill;
				r.Fill = brush;
				el = r;
			}
			else
			{
				Image img = new Image();
				img.Width = bm.Width;
				img.Height = bm.Height;
				img.Source = bm;
				el = img;
			}
			RenderCanvas.Children.Add(el);
			if (targetArea.HasValue)
			{
				Canvas.SetLeft(el, targetArea.Value.X);
				Canvas.SetTop(el, targetArea.Value.Y);
			}
			else
			{
				Canvas.SetLeft(el, 0);
				Canvas.SetTop(el, 0);
			}
		}
Esempio n. 35
0
 private void rdbScroll_CheckedChanged(object sender, EventArgs e)
 {
     if (rdbScroll.Checked) tileMode = TileMode.Scrolls;
 }
Esempio n. 36
0
        /// <summary>
        /// Handler for the mouse clicking and painting a tile or wall.
        /// </summary>
        public bool Click(int x, int y, TileMode mode)
        {
            if (x < 0 || y < 0 || x >= box.Width || y >= box.Height) return false;

            switch (mode)
            {
                case TileMode.Tiles: return clickTiles(x, y);
                case TileMode.Blocks: return clickBlocks(x, y);
                default: break;
            }
            return false;
        }
Esempio n. 37
0
 //public static int GetBpp(ImageFormat Format) { return Bpp[(uint)Format]; }
 public static Bitmap ToBitmap(byte[] Data, int Width, int Height, ImageFormat Format, TileMode TileMode, uint SwizzleMode, bool ExactSize = false)
 {
     return ToBitmap(Data, 0, Width, Height, Format, TileMode, SwizzleMode, ExactSize);
 }
Esempio n. 38
0
 private static ExtendMode GetExtendModeY(TileMode tileMode)
 {
     return (tileMode & TileMode.FlipY) != 0 ? ExtendMode.Mirror : ExtendMode.Wrap;
 }
Esempio n. 39
0
        public static unsafe Bitmap ToBitmap(byte[] Data, int Offset, int Width, int Height, ImageFormat Format, TileMode TileMode, uint SwizzleMode, bool ExactSize = false)
        {
            if (Data == null || Data.Length < 1 || Offset < 0 || Offset >= Data.Length || Width < 1 || Height < 1) return null;
            if (ExactSize && ((Width % 8) != 0 || (Height % 8) != 0)) return null;
            int physicalwidth = Width;
            int physicalheight = Height;
            if (!ExactSize)
            {
                Width = 1 << (int)Math.Ceiling(Math.Log(Width, 2));
                Height = 1 << (int)Math.Ceiling(Math.Log(Height, 2));
            }
            Bitmap bitm = new Bitmap(Width, Height);//physicalwidth, physicalheight);
            BitmapData d = bitm.LockBits(new Rectangle(0, 0, bitm.Width, bitm.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
            uint* res = (uint*)d.Scan0;
            int offs = Offset;//0;
            int stride = d.Stride / 4;
            switch (Format)
            {
                case ImageFormat.RGB565:
                    for (int y = 0; y < Height; y++)
                    {
                        for (int x = 0; x < Width; x++)
                        {
                            //if (x >= physicalwidth) continue;
                            if (y >= physicalheight) continue;
                            res[y * stride + x] =
                                GFXUtil.ConvertColorFormat(
                                    IOUtil.ReadU16LE(Data, offs),
                                    ColorFormat.RGB565,
                                    ColorFormat.ARGB8888);
                            offs += 2;
                        }
                    }
                    break;
                case ImageFormat.DXT5:
                    for (int y2 = 0; y2 < Height; y2 += 4)
                    {
                        for (int x2 = 0; x2 < Width; x2 += 4)
                        {
                            ulong a_data = IOUtil.ReadU64LE(Data, offs);
                            byte[] AlphaPalette = new byte[8];
                            AlphaPalette[0] = (byte)(a_data & 0xFF);
                            AlphaPalette[1] = (byte)((a_data >> 8) & 0xFF);
                            a_data >>= 16;
                            if (AlphaPalette[0] > AlphaPalette[1])
                            {
                                AlphaPalette[2] = (byte)((6 * AlphaPalette[0] + 1 * AlphaPalette[1]) / 7);
                                AlphaPalette[3] = (byte)((5 * AlphaPalette[0] + 2 * AlphaPalette[1]) / 7);
                                AlphaPalette[4] = (byte)((4 * AlphaPalette[0] + 3 * AlphaPalette[1]) / 7);
                                AlphaPalette[5] = (byte)((3 * AlphaPalette[0] + 4 * AlphaPalette[1]) / 7);
                                AlphaPalette[6] = (byte)((2 * AlphaPalette[0] + 5 * AlphaPalette[1]) / 7);
                                AlphaPalette[7] = (byte)((1 * AlphaPalette[0] + 6 * AlphaPalette[1]) / 7);
                            }
                            else
                            {
                                AlphaPalette[2] = (byte)((4 * AlphaPalette[0] + 1 * AlphaPalette[1]) / 5);
                                AlphaPalette[3] = (byte)((3 * AlphaPalette[0] + 2 * AlphaPalette[1]) / 5);
                                AlphaPalette[4] = (byte)((2 * AlphaPalette[0] + 3 * AlphaPalette[1]) / 5);
                                AlphaPalette[5] = (byte)((1 * AlphaPalette[0] + 4 * AlphaPalette[1]) / 5);
                                AlphaPalette[6] = 0;
                                AlphaPalette[7] = 255;
                            }
                            offs += 8;
                            ushort color0 = IOUtil.ReadU16LE(Data, offs);
                            ushort color1 = IOUtil.ReadU16LE(Data, offs + 2);
                            uint data = IOUtil.ReadU32LE(Data, offs + 4);
                            uint[] Palette = new uint[4];
                            Palette[0] = GFXUtil.ConvertColorFormat(color0, ColorFormat.RGB565, ColorFormat.ARGB8888);
                            Palette[1] = GFXUtil.ConvertColorFormat(color1, ColorFormat.RGB565, ColorFormat.ARGB8888);
                            Color a = System.Drawing.Color.FromArgb((int)Palette[0]);
                            Color b = System.Drawing.Color.FromArgb((int)Palette[1]);
                            if (color0 > color1)//1/3 and 2/3
                            {
                                Palette[2] = GFXUtil.ToColorFormat((a.R * 2 + b.R * 1) / 3, (a.G * 2 + b.G * 1) / 3, (a.B * 2 + b.B * 1) / 3, ColorFormat.ARGB8888);
                                Palette[3] = GFXUtil.ToColorFormat((a.R * 1 + b.R * 2) / 3, (a.G * 1 + b.G * 2) / 3, (a.B * 1 + b.B * 2) / 3, ColorFormat.ARGB8888);
                            }
                            else//1/2 and transparent
                            {
                                Palette[2] = GFXUtil.ToColorFormat((a.R + b.R) / 2, (a.G + b.G) / 2, (a.B + b.B) / 2, ColorFormat.ARGB8888);
                                Palette[3] = 0;
                            }

                            int q = 30;
                            int aq = 45;
                            for (int y3 = 0; y3 < 4; y3++)
                            {
                                for (int x3 = 0; x3 < 4; x3++)
                                {
                                    //if (x2 + x3 >= physicalwidth) continue;
                                    if (y2 + y3 >= physicalheight) continue;
                                    res[(y2 + y3) * stride + x2 + x3] = (Palette[(data >> q) & 3] & 0xFFFFFF) | ((uint)AlphaPalette[(a_data >> aq) & 7] << 24);
                                    q -= 2;
                                    aq -= 3;
                                }
                            }
                            offs += 8;
                        }
                        //	}
                        //}
                    }
                    break;
                /*case ImageFormat.ETC1://Some reference: http://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt
                case ImageFormat.ETC1A4:
                    {
                        for (int y = 0; y < Height; y += 8)
                        {
                            for (int x = 0; x < Width; x += 8)
                            {
                                for (int i = 0; i < 8; i += 4)
                                {
                                    for (int j = 0; j < 8; j += 4)
                                    {
                                        ulong alpha = 0xFFFFFFFFFFFFFFFF;
                                        ulong data = IOUtil.ReadU64BE(Data, offs);
                                        if (Format == ImageFormat.ETC1A4)
                                        {
                                            offs += 8;
                                            alpha = IOUtil.ReadU64BE(Data, offs);
                                        }
                                        bool diffbit = ((data >> 33) & 1) == 1;
                                        bool flipbit = ((data >> 32) & 1) == 1; //0: |||, 1: |-|
                                        int r1, r2, g1, g2, b1, b2;
                                        if (diffbit) //'differential' mode
                                        {
                                            int r = (int)((data >> 59) & 0x1F);
                                            int g = (int)((data >> 51) & 0x1F);
                                            int b = (int)((data >> 43) & 0x1F);
                                            r1 = (r << 3) | ((r & 0x1C) >> 2);
                                            g1 = (g << 3) | ((g & 0x1C) >> 2);
                                            b1 = (b << 3) | ((b & 0x1C) >> 2);
                                            r += (int)((data >> 56) & 0x7) << 29 >> 29;
                                            g += (int)((data >> 48) & 0x7) << 29 >> 29;
                                            b += (int)((data >> 40) & 0x7) << 29 >> 29;
                                            r2 = (r << 3) | ((r & 0x1C) >> 2);
                                            g2 = (g << 3) | ((g & 0x1C) >> 2);
                                            b2 = (b << 3) | ((b & 0x1C) >> 2);
                                        }
                                        else //'individual' mode
                                        {
                                            r1 = (int)((data >> 60) & 0xF) * 0x11;
                                            g1 = (int)((data >> 52) & 0xF) * 0x11;
                                            b1 = (int)((data >> 44) & 0xF) * 0x11;
                                            r2 = (int)((data >> 56) & 0xF) * 0x11;
                                            g2 = (int)((data >> 48) & 0xF) * 0x11;
                                            b2 = (int)((data >> 40) & 0xF) * 0x11;
                                        }
                                        int Table1 = (int)((data >> 37) & 0x7);
                                        int Table2 = (int)((data >> 34) & 0x7);
                                        for (int y3 = 0; y3 < 4; y3++)
                                        {
                                            for (int x3 = 0; x3 < 4; x3++)
                                            {
                                                if (x + j + x3 >= physicalwidth) continue;
                                                if (y + i + y3 >= physicalheight) continue;

                                                int val = (int)((data >> (x3 * 4 + y3)) & 0x1);
                                                bool neg = ((data >> (x3 * 4 + y3 + 16)) & 0x1) == 1;
                                                uint c;
                                                if ((flipbit && y3 < 2) || (!flipbit && x3 < 2))
                                                {
                                                    int add = ETC1Modifiers[Table1, val] * (neg ? -1 : 1);
                                                    c = GFXUtil.ToColorFormat((byte)(((alpha >> ((x3 * 4 + y3) * 4)) & 0xF) * 0x11), (byte)ColorClamp(r1 + add), (byte)ColorClamp(g1 + add), (byte)ColorClamp(b1 + add), ColorFormat.ARGB8888);
                                                }
                                                else
                                                {
                                                    int add = ETC1Modifiers[Table2, val] * (neg ? -1 : 1);
                                                    c = GFXUtil.ToColorFormat((byte)(((alpha >> ((x3 * 4 + y3) * 4)) & 0xF) * 0x11), (byte)ColorClamp(r2 + add), (byte)ColorClamp(g2 + add), (byte)ColorClamp(b2 + add), ColorFormat.ARGB8888);
                                                }
                                                res[(i + y3) * stride + x + j + x3] = c;
                                            }
                                        }
                                        offs += 8;
                                    }
                                }
                            }
                            res += stride * 8;
                        }
                    }
                    break;
                 * */
            }
            Detile(res, stride, Width, Height, physicalwidth, physicalheight, TileMode);
            bitm.UnlockBits(d);
            return bitm;
        }
Esempio n. 40
0
 private void rdbWide_CheckedChanged(object sender, EventArgs e)
 {
     if (rdbWide.Checked) tileMode = TileMode.Width;
 }
Esempio n. 41
0
 public void SetPostMode(bool value)
 {
     if (!value)
     {
         this.rdbTiles.Enabled = true;
         this.rdbBlocks.Enabled = true;
         this.rdbScroll.Enabled = true;
         this.rdbVariants.Enabled = false;
         this.rdbWide.Enabled = false;
         this.rdbScroll2.Enabled = false;
         if (rdbTiles.Checked) tileMode = TileMode.Tiles;
         else if (rdbBlocks.Checked) tileMode = TileMode.Blocks;
         else if (rdbScroll.Checked) tileMode = TileMode.Scrolls;
         this.btnConvert.Text = "Convert";
     }
     else
     {
         this.rdbTiles.Enabled = false;
         this.rdbBlocks.Enabled = false;
         this.rdbScroll.Enabled = false;
         this.rdbVariants.Enabled = true;
         this.rdbWide.Enabled = true;
         this.rdbScroll2.Enabled = true;
         if (rdbVariants.Checked) tileMode = TileMode.Variants;
         else if (rdbWide.Checked) tileMode = TileMode.Width;
         else if (rdbScroll2.Checked) tileMode = TileMode.Scrolls;
         this.btnConvert.Text = "Revert";
     }
 }
Esempio n. 42
0
 private void rdbVariants_CheckedChanged(object sender, EventArgs e)
 {
     if (rdbVariants.Checked) tileMode = TileMode.Variants;
 }
Esempio n. 43
0
        /// <summary>
        /// Handler for a single click on a tile.
        /// </summary>
        public void OneClick(int x, int y, TileMode mode, bool left)
        {
            if (x < 0 || y < 0 || x >= box.Width || y >= box.Height) return;

            switch (mode)
            {
                case TileMode.Variants:
                    clickTileVariant(x, y, left);
                    break;
                case TileMode.Scrolls:
                    clickScrollPlace(x, y);
                    break;
                case TileMode.Width:
                    clickToggleWidth(x, y);
                    break;
                default: break;
            }
        }
Esempio n. 44
0
 private static unsafe void Detile(uint* res, int stride, int width, int height, int physicalwidth, int physicalheight, TileMode Mode)
 {
     switch (Mode)
     {
         case Textures.TileMode.Tiled2DThin1:
             DetileTiled2DThin1(res, stride, width, height, physicalwidth, physicalheight);
             return;
         default:
             throw new Exception("Unsupported Tilemode!");
     }
 }
Esempio n. 45
0
 private void rdbBlocks_CheckedChanged(object sender, EventArgs e)
 {
     if (rdbBlocks.Checked) tileMode = TileMode.Blocks;
 }
Esempio n. 46
0
 private static Size CalculateIntermediateSize(
     TileMode tileMode,
     Size targetSize,
     Size destinationSize)
 {
     var result = tileMode == TileMode.None ? targetSize : destinationSize;
     return result;
 }
Esempio n. 47
0
 private void rdbTiles_CheckedChanged(object sender, EventArgs e)
 {
     if (rdbTiles.Checked) tileMode = TileMode.Tiles;
 }
Esempio n. 48
0
 protected static ExtendMode GetExtendModeX(TileMode tileMode)
 {
     return (tileMode & TileMode.FlipX) != 0 ? ExtendMode.Mirror : ExtendMode.Wrap;
 }