Пример #1
0
        private void imagesList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid     dataGrid     = sender as DataGrid;
            ImageWrapper imageWrapper = (ImageWrapper)dataGrid.SelectedItem;

            showImage(imageWrapper);
        }
Пример #2
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            List <ImageWrapper> images = new List <ImageWrapper>();
            int i = 0;

            for (int offset = 0; offset < (file.Length - 1); offset++)
            {
                if (file[offset] == 'L' && file[offset + 1] == 'e')
                {
                    int size = Utils.GetIntAtPosition(file, offset + 2);
                    if (size > 0 && size < 0x8000)
                    {
                        //ArrayPtr arrayPtr = new ArrayPtr(file, offset);
                        byte[]       data   = Malias2.Decompress(file, offset);
                        ImageWrapper result = new ImageWrapper(i, offset, data, "Malias2");
                        images.Add(result);
                        i++;
                    }
                }
                else if (file[offset] == 0x10)
                {
                    int size = file[offset + 1] | file[offset + 2] << 8 | file[offset + 3] << 16;
                    if (size > 0 && size < 0x8000 && size % 0x20 == 0)
                    {
                        byte[] data = LZ77.Decompress(file, offset);
                        if (data != null)
                        {
                            ImageWrapper result = new ImageWrapper(i, offset, data, "LZ77");
                            images.Add(result);
                            i++;
                        }
                    }
                }
            }
            imagesList.ItemsSource = images;
        }
Пример #3
0
        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            ImageWrapper imageWrapper = (ImageWrapper)imagesList.SelectedItem;

            showImage(imageWrapper);
        }
Пример #4
0
        private void widthImage_TextChanged(object sender, TextChangedEventArgs e)
        {
            ImageWrapper imageWrapper = (ImageWrapper)imagesList.SelectedItem;

            showImage(imageWrapper);
        }
Пример #5
0
        private void showImage(ImageWrapper imageWrapper)
        {
            canvas.Children.Clear();
            int width  = 256;
            int offset = 0;

            if (Int32.TryParse(widthImage.Text, out int result))
            {
                if (result > 0)
                {
                    width = result * 8;
                }
            }
            if (Int32.TryParse(offsetImage.Text, out result))
            {
                if (result > 0)
                {
                    offset = result;
                }
            }
            if (bit_mode.IsChecked.Value)
            {
                if (imageWrapper.data.Length % 0x40 == 0)
                {
                    List <byte[]> tiles = imageWrapper.getTiles(0x40);
                    tiles.RemoveRange(0, offset);
                    int             height = (int)Math.Ceiling((double)tiles.Count / (width / 8)) * 8;
                    WriteableBitmap wbm    = new WriteableBitmap(width, height, 48, 48, PixelFormats.Gray8, null);
                    for (int y = 0; y < height / 8; y++)
                    {
                        for (int x = 0; x < width / 8; x++)
                        {
                            if (x + y * (width / 8) >= tiles.Count)
                            {
                                break;
                            }
                            wbm.WritePixels(new Int32Rect(x * 8, y * 8, 8, 8), tiles[x + y * (width / 8)], 8, 0);
                        }
                    }
                    Image tile = new Image();
                    tile.Source = wbm;
                    Canvas.SetTop(tile, 0);
                    Canvas.SetLeft(tile, 0);
                    canvas.Children.Add(tile);
                }
            }
            else
            {
                if (imageWrapper.data.Length % 0x20 == 0)
                {
                    List <byte[]> tiles = imageWrapper.getTiles(0x20);
                    tiles.RemoveRange(0, offset);
                    int             height = (int)Math.Ceiling((double)tiles.Count / (width / 8)) * 8;
                    WriteableBitmap wbm    = new WriteableBitmap(width, height, 48, 48, PixelFormats.Gray4, null);
                    for (int y = 0; y < height / 8; y++)
                    {
                        for (int x = 0; x < width / 8; x++)
                        {
                            if (x + y * (width / 8) >= tiles.Count)
                            {
                                break;
                            }
                            wbm.WritePixels(new Int32Rect(x * 8, y * 8, 8, 8), flip(tiles[x + y * (width / 8)]), 4, 0);
                        }
                    }
                    Image tile = new Image();
                    tile.Source = wbm;
                    Canvas.SetTop(tile, 0);
                    Canvas.SetLeft(tile, 0);
                    canvas.Children.Add(tile);
                }
            }
        }