示例#1
0
        public ImageFileData GetImageByName(string request_file_name)
        {
            Log("GetImageByName");
            try
            {
                if (string.IsNullOrEmpty(request_file_name))
                {
                    throw new ArgumentException("Invalid requested file name!", request_file_name);
                }

                IEnumerable <FileInfo> allImageFilesList = GetAllImageFiles();
                FileInfo requestedImageFile = null;
                requestedImageFile = allImageFilesList.SingleOrDefault(f => f.Name == request_file_name);
                if (requestedImageFile == null)
                {
                    throw new ArgumentException("File that you has requested doesn't exist!", request_file_name);
                }

                ImageFileData imageFileData = new ImageFileData()
                {
                    FileName = requestedImageFile.Name, LastDateModified = requestedImageFile.LastWriteTime
                };
                byte[] imageBytes = File.ReadAllBytes(requestedImageFile.FullName);
                imageFileData.ImageData = imageBytes;
                return(imageFileData);
            }
            catch (Exception e)
            {
                ServerFault fault = new ServerFault();
                fault.FriendlyDiscription = "Some problems just has been occured on service host!";
                fault.Discription         = e.Message;
                throw new FaultException <ServerFault>(fault, new FaultReason(fault.Discription));
            }
        }
示例#2
0
        public bool SaveImage(int albumId, ImageFileData imageFileData, out string url)
        {
            Album album = context.Albums.Find(albumId);

            if (album == null)
            {
                url = "";
                return(false);
            }

            AlbumImageData imageToAdd = new AlbumImageData()
            {
                AlbumId = albumId
            };

            context.AlbumImages.Add(imageToAdd);
            context.SaveChanges();
#warning yossim: jpg extension shouldn't be hard coded
            imageToAdd.URL = ImageStoreUtilities.GenerateUrl(albumId, imageToAdd.AlbumImageDataId, ".jpg");

            {
#warning yossim: Should be transactive
                ImageStoreUtilities.Store(imageToAdd.URL, imageFileData.ImageStream);
                context.SaveChanges();
            }

            url = imageToAdd.URL;
            return(true);
        }
示例#3
0
        public bool AddImage(int albumId, ImageFileData imageFileData, out string errorString)
        {
            IAlbumsDataManager albumsDataMan = managersFactory.CreateAlbumsManager();

            if (albumsDataMan == null)
            {
                errorString = "Failed retrieving AlbumsDataManager";
                return(false);
            }

            IImagesManager imagesMan = managersFactory.CreateImagesManager();

            if (imagesMan == null)
            {
                errorString = "Failed retrieving ImagesManager";
                return(false);
            }

            string url;

            if (!imagesMan.SaveImage(albumId, imageFileData, out url))
            {
                errorString = "Failed saving image";
                return(false);
            }

            errorString = "";
            return(true);
        }
示例#4
0
        public void UploadImage(byte[] imageData, string imageName)
        {
            IEnumerable <ImageFileData> allImagesFileData = GetAllImagesInfo(false);

            if (allImagesFileData == null)
            {
                return;
            }
            if (allImagesFileData.SingleOrDefault(p => p.FileName == imageName) != null)
            {
                faultProcessor.ProcessMessage("Image with the same name already exists");
            }

            ImageFileData data = new ImageFileData()
            {
                FileName = imageName, LastDateModified = DateTime.Now, ImageData = imageData
            };

            try
            {
                ImageServiceProxy.UploadImage(data);
            }
            catch (Exception ex)
            {
                faultProcessor.ProcessException(ex);
                return;
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        ImageServiceClientManager   manager        = (ImageServiceClientManager)Session["Manager"];
        IEnumerable <ImageFileData> imagesFileData = (IEnumerable <ImageFileData>)Session["ImagesFileData"];

        if (manager == null || imagesFileData == null)
        {
            return;
        }
        string fileName = Request.QueryString["fileName"];

        byte[] imageData = null;

        ImageFileData imageFileData = imagesFileData.SingleOrDefault(p => p.FileName == fileName);

        if (imageFileData != null && imageFileData.ImageData != null)
        {
            imageData = imageFileData.ImageData;
        }
        else
        {
            imageData = manager.DownloadImage(fileName);
        }
        if (imageData != null)
        {
            Response.BinaryWrite(imageData);
        }
    }
示例#6
0
        public IEnumerable <ImageFileData> GetAllImagesList(bool withFilesData)
        {
            Log("GetAllImagesList");
            List <ImageFileData> images_collection = new List <ImageFileData>();

            try
            {
                foreach (FileInfo fileInfo in GetAllImageFiles())
                {
                    ImageFileData imageFileData = new ImageFileData()
                    {
                        FileName = fileInfo.Name, LastDateModified = fileInfo.LastWriteTime
                    };
                    byte[] imageBytes = null;
                    if (withFilesData)
                    {
                        imageBytes = File.ReadAllBytes(fileInfo.FullName);
                    }
                    imageFileData.ImageData = imageBytes;
                    images_collection.Add(imageFileData);
                }
            }
            catch (Exception e)
            {
                ServerFault fault = new ServerFault();
                fault.FriendlyDiscription = "Some problems just has been occured on server!";
                fault.Discription         = e.Message;
                throw new FaultException <ServerFault>(fault, new FaultReason(fault.Discription));
            }

            AddUpdateToSessionTable(images_collection.Count);
            return(images_collection);
        }
        private void UploadButton_Click(object sender, EventArgs e)
        {
            string uploadedRowFileName = string.Empty;

            using (OpenFileDialog openImageFileDialog = new OpenFileDialog())
            {
                openImageFileDialog.InitialDirectory = @"C:\Users\bdudnik\Pictures";
                openImageFileDialog.Filter           = "Image Files |*.jpg;*.gif;*.bmp;*.png;*.jpeg|All Files|*.*";
                openImageFileDialog.FilterIndex      = 2;
                openImageFileDialog.RestoreDirectory = true;
                if (openImageFileDialog.ShowDialog() == DialogResult.OK)
                {
                    uploadedRowFileName = Path.GetFileName(openImageFileDialog.FileName);
                    manager.UploadImage(openImageFileDialog.FileName);
                    UpdateImagesInfoGrid();
                }
            }
            var           dataSource = (BindingList <ImageFileData>)ImagesInfoGrid.DataSource;
            ImageFileData rowObject  = dataSource.SingleOrDefault(p => p.FileName.Equals(uploadedRowFileName));

            if (rowObject != null)
            {
                ImagesInfoGrid.Rows[dataSource.IndexOf(rowObject)].Selected = true;
            }
        }
        private void UpdateImagesInfoGrid()
        {
            string selectedRowFileName = string.Empty;

            if (ImagesInfoGrid.SelectedRows.Count != 0)
            {
                selectedRowFileName = ((ImageFileData)ImagesInfoGrid.SelectedRows[0].DataBoundItem).FileName;
            }
            IEnumerable <ImageFileData> imagesInfo = manager.GetAllImagesInfo(true);

            if (imagesInfo == null)
            {
                return;
            }
            ImagesInfoGrid.Rows.Clear();
            var bindingList = new BindingList <ImageFileData>(new List <ImageFileData>(imagesInfo));

            ImagesInfoGrid.Invoke(new MethodInvoker(delegate() { ImagesInfoGrid.DataSource = bindingList; }));

            ImageFileData rowObject = bindingList.SingleOrDefault(p => p.FileName.Equals(selectedRowFileName));

            if (rowObject != null)
            {
                ImagesInfoGrid.Rows[bindingList.IndexOf(rowObject)].Selected = true;
            }
        }
        public BlogPostImagePropertiesInfo(BlogPostImageData imageData, ImageDecoratorsList decorators)
        {
            _imageData = imageData;
            ImageFileData sourceFile = imageData.GetImageSourceFile();

            Init(sourceFile.Uri, new Size(sourceFile.Width, sourceFile.Height), decorators);
        }
示例#10
0
        /// <summary>
        /// Saves the emoticon image to disk and returns the path. Should only be called if the emoticon image has not been saved previously for this blog post.
        /// </summary>
        private Uri CreateInlineImage(Emoticon emoticon)
        {
            Debug.Assert(_imageEditingContext.ImageList != null && _imageEditingContext.SupportingFileService != null, "ImageEditingContext not initalized yet.");

            Stream          emoticonStream = StreamHelper.AsStream(ImageHelper.GetBitmapBytes(emoticon.Bitmap, ImageFormat.Png));
            ISupportingFile sourceFile     = _imageEditingContext.SupportingFileService.CreateSupportingFile(emoticon.Id + emoticon.FileExtension, emoticonStream);
            ImageFileData   sourceFileData = new ImageFileData(sourceFile, emoticon.Bitmap.Width, emoticon.Bitmap.Height, ImageFileRelationship.Source);

            BlogPostImageData imageData = new BlogPostImageData(sourceFileData);

            if (GlobalEditorOptions.SupportsFeature(ContentEditorFeature.ShadowImageForDrafts))
            {
                imageData.InitShadowFile(_imageEditingContext.SupportingFileService);
            }

            emoticonStream.Seek(0, SeekOrigin.Begin);
            ISupportingFile inlineFile = _imageEditingContext.SupportingFileService.CreateSupportingFile(emoticon.Id + emoticon.FileExtension, emoticonStream);

            imageData.InlineImageFile = new ImageFileData(inlineFile, emoticon.Bitmap.Width, emoticon.Bitmap.Height, ImageFileRelationship.Inline);

            _imageEditingContext.ImageList.AddImage(imageData);

            SetInlineImageUri(emoticon, imageData.InlineImageFile.Uri);

            return(imageData.InlineImageFile.Uri);
        }
示例#11
0
        private void Upload()
        {
            string uploadedFileName = string.Empty;

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.InitialDirectory = @"C:\Users\bdudnik\Pictures";
            dlg.Filter           = "Image Files |*.jpg;*.gif;*.bmp;*.png;*.jpeg|All Files|*.*";
            dlg.RestoreDirectory = true;

            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                manager.UploadImage(dlg.FileName);
                uploadedFileName = Path.GetFileName(dlg.FileName);
                UpdateImagesInfoGrid();
            }

            ImageFileData rowObject = model.ImagesFileData.SingleOrDefault(p => p.FileName.Equals(uploadedFileName));

            if (rowObject != null)
            {
                int index = model.ImagesFileData.IndexOf(rowObject);
                imageFilesGrid.ScrollIntoView(imageFilesGrid.Items[index]);
                DataGridRow row = (DataGridRow)imageFilesGrid.ItemContainerGenerator.ContainerFromIndex(index);
                row.IsSelected = true;
            }
        }
示例#12
0
        private string CreatePartImage(Rect puzzlePartRect)
        {
            // Load main image
            ImageFileData data = new ImageFileData();

            Bitmap imageBM = new Bitmap(Bitmap.FromFile(ImageData.URL));

            Bitmap puzzlePartBM = new Bitmap(puzzlePartRect.Width, puzzlePartRect.Height);

            for (int i = 0; i < puzzlePartRect.Width; i++)
            {
                for (int j = 0; j < puzzlePartRect.Height; j++)
                {
                    puzzlePartBM.SetPixel(i, j, imageBM.GetPixel(puzzlePartRect.MinX + i, puzzlePartRect.MinY + j));
                }
            }

            ManagersFactory factory       = ManagersFactory.Create();
            IImagesManager  imagesManager = factory.CreateImagesManager();
            string          URL;

            imagesManager.SaveImage(AlbumId, puzzlePartBM, out URL);

            return(URL);
        }
示例#13
0
        public void SetImageData(ImageFileData imageData)
        {
            this.imageData = imageData;

            image.texture             = imageData.texture;
            filenameText.text         = imageData.fileName;
            timeSinceCreatedText.text =
                string.Format(createdText, DateTimeHelper.GetHoursSinceCreated(imageData.timeCreated));
        }
示例#14
0
        //-----------------------------------Download image----------------------------------------
        public byte[] DownloadImage(string fileName)
        {
            ImageFileData image = null;

            try
            {
                image = ImageServiceProxy.GetImageByName(fileName);
            }
            catch (Exception ex)
            {
                faultProcessor.ProcessException(ex);
                return(null);
            }
            return(image.ImageData);
        }
示例#15
0
    private static ImageData LoadImageData(ImageFileData imageFileData)
    {
        if (string.IsNullOrEmpty(imageFileData.Id) ||
            string.IsNullOrEmpty(imageFileData.Name) ||
            string.IsNullOrEmpty(imageFileData.RawImageData))
        {
            return(null);
        }

        byte[] textureData = System.Convert.FromBase64String(imageFileData.RawImageData);
        if (textureData == null)
        {
            return(null);
        }

        var texture = new Texture2D(2, 2);

        texture.filterMode = FilterMode.Point;
        texture.wrapMode   = TextureWrapMode.Clamp;
        if (!texture.LoadImage(textureData))
        {
            return(null);
        }

        int size     = Mathf.NextPowerOfTwo(Mathf.Max(texture.width, texture.height));
        var texture2 = new Texture2D(size, size);

        texture2.filterMode = FilterMode.Point;
        texture2.wrapMode   = TextureWrapMode.Clamp;

        for (int x = 0; x < texture.width; x++)
        {
            for (int y = 0; y < texture.height; y++)
            {
                texture2.SetPixel(x, y, texture.GetPixel(x, y));
            }
        }
        texture2.Apply(false);

        var imageData = new ImageData();

        imageData.Init(imageFileData.Id, imageFileData.Name, texture.width, texture.height, texture2);

        return(imageData);
    }
示例#16
0
            public void ParseUsedTextureDatas()
            {
                Console.WriteLine("Start Parsing Texture List.");
                string textureFilePath;

                while (res.ParseNextTextureFilePath(out textureFilePath))
                {
                    Console.WriteLine("  Find used Texture : {0}.", textureFilePath);

                    SubTaskParam param = new SubTaskParam();
                    param.TextureFilePath = textureFilePath;
                    param.TaskGroup       = this;

                    //Task<ImageFileData> readImageFileTask =
                    Task <ImageFileData> .Factory.StartNew(arg =>
                    {
                        SubTaskParam p = arg as SubTaskParam;
                        MaterialTaskGroup argTaskGroup = param.TaskGroup;

                        Console.WriteLine("  Read Image File : {0}", p.TextureFilePath);
                        ImageFileData imgFileData = res.ReadFileData <ImageFileData>();
                        return(imgFileData);
                    }, param, CTS.Token, TaskCreationOptions.AttachedToParent, SchedulerIO)
                    .ContinueWith((antecedent, arg) =>
                    {
                        SubTaskParam p            = arg as SubTaskParam;
                        ImageFileData imgFileData = antecedent.Result as ImageFileData;

                        Console.WriteLine("  Parse Image Data : {0}", p.TextureFilePath);
                        ImageData imgData = res.ParseImageInfo(imgFileData);
                        return(imgData);
                    }, param, CTS.Token, TaskContinuationOptions.AttachedToParent, TaskScheduler.Default)
                    .ContinueWith((antecedent, arg) =>
                    {
                        SubTaskParam p        = arg as SubTaskParam;
                        ImageData imgFileData = antecedent.Result as ImageData;

                        Console.WriteLine("  Create Texture from Image Data : {0}", p.TextureFilePath);
                        Texture texture = res.CreateTexture(p.TextureFilePath, imgFileData);
                        textures.Add(texture);
                    }, param, CTS.Token, TaskContinuationOptions.AttachedToParent, SchedulerMain);
                }
            }
示例#17
0
        public void UploadImage(ImageFileData uploading_image)
        {
            Log("UploadImage");
            try
            {
                if (string.IsNullOrEmpty(uploading_image.FileName))
                {
                    throw new ArgumentException("Invalid upldoading file name", uploading_image.FileName);
                }

                if (uploading_image.ImageData == null || uploading_image.ImageData.Length == 0)
                {
                    throw new ArgumentException("Uploaded file-data is empty!");
                }

                string newImageFileName = uploading_image.FileName;
                string uploadFolder     = ConfigurationManager.AppSettings["UploadFolder"];
                string newImageFilePath = Path.Combine(uploadFolder, newImageFileName);

                if (File.Exists(newImageFilePath))
                {
                    throw new FaultException <FileAlreadyExists>(new FileAlreadyExists {
                        FileName = newImageFileName
                    }, new FaultReason(string.Empty));
                }

                using (Stream targetStream = new FileStream(newImageFilePath, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    targetStream.Write(uploading_image.ImageData, 0, uploading_image.ImageData.Length);
                }
            }

            catch (FaultException e)
            {
                throw e;
            }
            catch (Exception)
            {
                HostStorageException fault = new HostStorageException();
                fault.Description = "Prodlems with images storage on host";
                throw new FaultException <HostStorageException>(fault, new FaultReason(fault.Description));
            }
        }
示例#18
0
        public ImageFileData GetImageByName(string request_file_name)
        {
            Log("GetImageByName");
            try
            {
                if (string.IsNullOrEmpty(request_file_name))
                {
                    throw new FaultException <InvalidFileName>(new InvalidFileName {
                        InvalidName = request_file_name
                    }, new FaultReason(string.Empty));
                }

                IEnumerable <FileInfo> allImageFilesList = GetAllImageFiles();
                FileInfo requestedImageFile = null;
                requestedImageFile = allImageFilesList.SingleOrDefault(f => f.Name == request_file_name);
                if (requestedImageFile == null)
                {
                    throw new FaultException <FileNotFound>(new FileNotFound {
                        FileName = request_file_name
                    }, new FaultReason(string.Empty));
                }

                ImageFileData imageFileData = new ImageFileData()
                {
                    FileName = requestedImageFile.Name, LastDateModified = requestedImageFile.LastWriteTime
                };
                byte[] imageBytes = File.ReadAllBytes(requestedImageFile.FullName);
                imageFileData.ImageData = imageBytes;
                return(imageFileData);
            }

            catch (FaultException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                HostStorageException fault = new HostStorageException();
                fault.Description = "Prodlems with images storage on host";
                throw new FaultException <HostStorageException>(fault, new FaultReason(string.Empty));
            }
        }
示例#19
0
        public void UploadImage(ImageFileData uploading_image)
        {
            Log("UploadImage");
            try
            {
                if (string.IsNullOrEmpty(uploading_image.FileName))
                {
                    throw new ArgumentException("Invalid upldoading file name", uploading_image.FileName);
                }

                if (uploading_image.ImageData == null || uploading_image.ImageData.Length == 0)
                {
                    throw new ArgumentException("Uploaded file-data is empty!");
                }

                string newImageFileName = uploading_image.FileName;
                string uploadFolder     = ConfigurationManager.AppSettings["UploadFolder"];
                string newImageFilePath = Path.Combine(uploadFolder, newImageFileName);

                try
                {
                    using (Stream targetStream = new FileStream(newImageFilePath, FileMode.OpenOrCreate, FileAccess.Write))
                    {
                        targetStream.Write(uploading_image.ImageData, 0, uploading_image.ImageData.Length);
                    }
                }
                catch (IOException)
                {
                    throw new IOException("Error writing new file or overwriting existed file");
                }
            }
            catch (Exception e)
            {
                ServerFault fault = new ServerFault();
                fault.FriendlyDiscription = "Some problems just has been occured on service host!";
                fault.Discription         = e.Message;
                throw new FaultException <ServerFault>(fault, new FaultReason(fault.Discription));
            }
        }
示例#20
0
        static void SingleThreadLoadingMaterial()
        {
            MockMaterialRes res = new MockMaterialRes();

            //Read Material File into memory.

            Console.WriteLine("Read Material File.");
            MaterialFileData matFileData = res.ReadFileData <MaterialFileData>();

            Console.WriteLine("Parse Material Data.");
            MaterialData matData = res.ParseMaterialInfo(matFileData);

            Console.WriteLine("Create Material Instance.");
            Material material = res.CreateMaterial(matData);

            Console.WriteLine("Start Parsing Texture List.");
            string textureFilePath;

            while (res.ParseNextTextureFilePath(out textureFilePath))
            {
                Console.WriteLine("\n  Find used Texture: {0}", textureFilePath);

                Console.WriteLine("  Read Image File.");
                ImageFileData imgFileData = res.ReadFileData <ImageFileData>();

                Console.WriteLine("  Parse Image Data.");
                ImageData imgData = res.ParseImageInfo(imgFileData);

                Console.WriteLine("  Create Texture from Image Data.");
                Texture texture = res.CreateTexture(textureFilePath, imgData);

                Console.WriteLine("  Assemble Texture into Material Instance.");
                material.AddTexture(texture);
            }

            material.PrintTextureNames();
            Console.WriteLine("Loading Finished.");
        }
示例#21
0
        private void UpdateButton_Click(object sender, RoutedEventArgs e)
        {
            string selectedFileName = string.Empty;

            if (imageFilesGrid.SelectedItem != null)
            {
                selectedFileName = ((ImageFileData)imageFilesGrid.SelectedItem).FileName;
            }

            model.ImagesFileData = new ObservableCollection <ImageFileData>(manager.GetAllImagesInfo(false));

            if (selectedFileName != string.Empty)
            {
                ImageFileData rowObject = model.ImagesFileData.SingleOrDefault(p => p.FileName.Equals(selectedFileName));
                if (rowObject != null)
                {
                    int index = model.ImagesFileData.IndexOf(rowObject);
                    imageFilesGrid.ScrollIntoView(imageFilesGrid.Items[index]);
                    DataGridRow row = (DataGridRow)imageFilesGrid.ItemContainerGenerator.ContainerFromIndex(index);
                    row.IsSelected = true;
                }
            }
        }
示例#22
0
        public IEnumerable <ImageFileData> GetAllImagesList(bool withFilesData)
        {
            Log("GetAllImagesList");
            List <ImageFileData> images_collection = new List <ImageFileData>();

            try
            {
                IEnumerable <FileInfo> allImageFiles = GetAllImageFiles();
                if (allImageFiles == null)
                {
                    return(null);
                }

                foreach (FileInfo fileInfo in allImageFiles)
                {
                    ImageFileData imageFileData = new ImageFileData()
                    {
                        FileName = fileInfo.Name, LastDateModified = fileInfo.LastWriteTime
                    };
                    byte[] imageBytes = null;
                    if (withFilesData)
                    {
                        imageBytes = File.ReadAllBytes(fileInfo.FullName);
                    }
                    imageFileData.ImageData = imageBytes;
                    images_collection.Add(imageFileData);
                }
            }
            catch (Exception)
            {
                HostStorageException fault = new HostStorageException();
                fault.Description = "Prodlems with images storage on host";
                throw new FaultException <HostStorageException>(fault, new FaultReason(string.Empty));
            }
            return(images_collection);
        }
示例#23
0
        public void UploadImage(byte[] imageData, string imageName)
        {
            IEnumerable <ImageFileData> allImagesFileData = GetAllImagesInfo(false);

            if (allImagesFileData == null)
            {
                return;
            }

            ImageFileData data = new ImageFileData()
            {
                FileName = imageName, LastDateModified = DateTime.Now, ImageData = imageData
            };

            try
            {
                ImageServiceProxy.UploadImage(data);
            }
            catch (Exception ex)
            {
                faultProcessor.ProcessException(ex);
                return;
            }
        }
        public override BitmapUW LoadImageAt(int index, bool Alpha)
        {
            if (ImageFileDataLoaded == false)
            {
                if (!LoadImageFile())
                {
                    return(base.LoadImageAt(index));
                }
            }
            else
            {
                if (ImageCache[index] != null)
                {
                    return(ImageCache[index]);
                }
            }


            long imageOffset = Util.getValAtAddress(ImageFileData, (index * 4) + 3, 32);

            if (imageOffset >= ImageFileData.GetUpperBound(0))
            {//Image out of range
                return(base.LoadImageAt(index));
            }


            switch (Util.getValAtAddress(ImageFileData, imageOffset, 8)) //File type
            {
            case 0x4:                                                    //8 bit uncompressed
            {
                int BitMapWidth  = (int)Util.getValAtAddress(ImageFileData, imageOffset + 1, 8);
                int BitMapHeight = (int)Util.getValAtAddress(ImageFileData, imageOffset + 2, 8);
                imageOffset       = imageOffset + 5;
                ImageCache[index] = Image(this, ImageFileData, imageOffset, index, BitMapWidth, BitMapHeight, "name_goes_here", PaletteLoader.Palettes[PaletteNo], Alpha, BitmapUW.ImageTypes.EightBitUncompressed);
                return(ImageCache[index]);
            }

            case 0x8:    //4 bit run-length
            {
                char[] imgNibbles;
                int    auxPalIndex;

                int BitMapWidth  = (int)Util.getValAtAddress(ImageFileData, imageOffset + 1, 8);
                int BitMapHeight = (int)Util.getValAtAddress(ImageFileData, imageOffset + 2, 8);
                if (!useOverrideAuxPalIndex)
                {
                    auxPalIndex = (int)Util.getValAtAddress(ImageFileData, imageOffset + 3, 8);
                }
                else
                {
                    auxPalIndex = OverrideAuxPalIndex;
                }
                int datalen = (int)Util.getValAtAddress(ImageFileData, imageOffset + 4, 16);
                imgNibbles  = new char[Math.Max(BitMapWidth * BitMapHeight * 2, (datalen + 5) * 2)];
                imageOffset = imageOffset + 6;          //Start of raw data.
                copyNibbles(ImageFileData, ref imgNibbles, datalen, imageOffset);
                int[]  aux       = PaletteLoader.LoadAuxilaryPalIndices(main.basepath + AuxPalPath, auxPalIndex);
                char[] RawImg    = DecodeRLEBitmap(imgNibbles, datalen, BitMapWidth, BitMapHeight, 4);
                char[] OutputImg = ApplyAuxPal(RawImg, aux);
                ImageCache[index] = Image(this, OutputImg, 0, index, BitMapWidth, BitMapHeight, "name_goes_here", PaletteLoader.Palettes[PaletteNo], Alpha, BitmapUW.ImageTypes.FourBitRunLength);
                ImageCache[index].UncompressedData = RawImg;
                ImageCache[index].SetAuxPalRef(aux);
                ImageCache[index].AuxPalNo = auxPalIndex;
                return(ImageCache[index]);
            }

            case 0xA:    //4 bit uncompressed
            {
                char[] imgNibbles;
                int    auxPalIndex;
                int    datalen;
                int    BitMapWidth  = (int)Util.getValAtAddress(ImageFileData, imageOffset + 1, 8);
                int    BitMapHeight = (int)Util.getValAtAddress(ImageFileData, imageOffset + 2, 8);
                if (!useOverrideAuxPalIndex)
                {
                    auxPalIndex = (int)Util.getValAtAddress(ImageFileData, imageOffset + 3, 8);
                }
                else
                {
                    auxPalIndex = OverrideAuxPalIndex;
                }
                datalen     = (int)Util.getValAtAddress(ImageFileData, imageOffset + 4, 16);
                imgNibbles  = new char[Math.Max(BitMapWidth * BitMapHeight * 2, (5 + datalen) * 2)];
                imageOffset = imageOffset + 6;          //Start of raw data.
                copyNibbles(ImageFileData, ref imgNibbles, datalen, imageOffset);
                //Palette auxpal = PaletteLoader.LoadAuxilaryPal(main.basepath + AuxPalPath, PaletteLoader.Palettes[PaletteNo], auxPalIndex);
                int[]  aux       = PaletteLoader.LoadAuxilaryPalIndices(main.basepath + AuxPalPath, auxPalIndex);
                char[] OutputImg = ApplyAuxPal(imgNibbles, aux);
                ImageCache[index] = Image(this, OutputImg, 0, index, BitMapWidth, BitMapHeight, "name_goes_here", PaletteLoader.Palettes[PaletteNo], Alpha, BitmapUW.ImageTypes.FourBitUncompress);
                ImageCache[index].UncompressedData = OutputImg;
                ImageCache[index].SetAuxPalRef(aux);
                ImageCache[index].AuxPalNo   = auxPalIndex;
                ImageCache[index].FileOffset = imageOffset;
                return(ImageCache[index]);
            }

            //break;
            default:
            {
                int BitMapWidth  = (int)Util.getValAtAddress(ImageFileData, imageOffset + 1, 8);
                int BitMapHeight = (int)Util.getValAtAddress(ImageFileData, imageOffset + 2, 8);
                if (FileName.ToUpper().EndsWith("PANELS.GR"))
                {        //Check to see if the file is panels.gr
                    if (index >= 4)
                    {
                        return(base.LoadImageAt(0));
                    }                          //new Bitmap(2, 2);
                    BitMapWidth  = 83;         //getValAtAddress(textureFile, textureOffset + 1, 8);
                    BitMapHeight = 114;        // getValAtAddress(textureFile, textureOffset + 2, 8);
                    if (main.curgame == main.GAME_UW2)
                    {
                        BitMapWidth  = 79;
                        BitMapHeight = 112;
                    }
                    imageOffset       = Util.getValAtAddress(ImageFileData, (index * 4) + 3, 32);
                    ImageCache[index] = Image(this, ImageFileData, imageOffset, index, BitMapWidth, BitMapHeight, "name_goes_here", PaletteLoader.Palettes[PaletteNo], Alpha, BitmapUW.ImageTypes.EightBitUncompressed);
                    return(ImageCache[index]);
                }
                break;
            }
            }

            return(base.LoadImageAt(0));
        }
示例#25
0
 public ImageData ParseImageInfo(ImageFileData fileData)
 {
     Thread.Sleep(500);
     return(new ImageData());
 }
        private Traffic GetTerrain_CMD(string args)
        {
            ResponseType responseType = ResponseType.Failed;
            int          seed         = 0;
            int          width        = 0;
            int          height       = 0;
            IModule      module       = null;
            List <GradientPresets.GradientKeyData> gradient = new List <GradientPresets.GradientKeyData>();
            MapData      mdata;
            MessageTypes type = MessageTypes.None;

            string[] TextureFiles = new string[0];
            string   message      = string.Empty;

            if (_server.WorldLoaded)
            {
                if (_server.Users.SessionKeyExists(args))
                {
                    string         user    = _server.Users.GetConnectedUser(args).Name;
                    TerrainBuilder builder = _server.Worlds.CurrentWorld.Terrain;
                    responseType = ResponseType.Successfull;
                    seed         = builder.Seed;
                    width        = builder.Width;
                    height       = builder.Height;
                    module       = builder.NoiseModule;
                    gradient     = new List <GradientPresets.GradientKeyData>(builder.GradientPreset);
                    TextureFiles = new List <string>(GradientCreator.TextureFiles.Keys).ToArray();
                    message      = "success";

                    // make sure images are cleared. They will be sent seperatly.
                    for (int i = 0; i < gradient.Count; i++)
                    {
                        gradient[i].images.Clear();
                    }

                    mdata = new MapData(responseType, seed, width, height, gradient, TextureFiles, message);
                    string sendStr   = JsonConvert.SerializeObject(mdata);
                    string moduleStr = JsonConvert.SerializeObject(module, new JsonSerializerSettings {
                        TypeNameHandling = TypeNameHandling.All
                    });
                    _server.SockServ.Send(user, "setterrainmodule", moduleStr);
                    _server.SockServ.Send(user, "setterraindata", sendStr);


                    System.Threading.ManualResetEvent reset = new System.Threading.ManualResetEvent(false);
                    foreach (string imageName in GradientCreator.TextureFiles.Keys)
                    {
                        //reset.WaitOne(1);
                        Color[]       image       = ColorConvert.LibColList(GradientCreator.TextureFiles[imageName]);
                        ImageFileData imageStruct = new ImageFileData(imageName, image);
                        string        imageStr    = JsonConvert.SerializeObject(imageStruct);
                        _server.SockServ.Send(user, "setimage", imageStr);
                        //Logger.Log("sent image: {0}", imageName);
                    }
                    message = "success";
                    type    = MessageTypes.Success;
                    return(new Traffic("message", JsonConvert.SerializeObject(new Message("_server_", type, message))));
                }
                else
                {
                    message = "Invalid session key";
                    type    = MessageTypes.Not_Logged_in;
                    return(new Traffic("message", JsonConvert.SerializeObject(new Message("_server_", type, message))));
                }
            }
            message = "World not loaded";
            type    = MessageTypes.World_Not_Loaded;
            return(new Traffic("message", JsonConvert.SerializeObject(new Message("_server_", type, message))));
        }
        /// <summary>
        /// Saves the emoticon image to disk and returns the path. Should only be called if the emoticon image has not been saved previously for this blog post.
        /// </summary>
        private Uri CreateInlineImage(Emoticon emoticon)
        {
            Debug.Assert(_imageEditingContext.ImageList != null && _imageEditingContext.SupportingFileService != null, "ImageEditingContext not initalized yet.");

            Stream emoticonStream = StreamHelper.AsStream(ImageHelper.GetBitmapBytes(emoticon.Bitmap, ImageFormat.Png));
            ISupportingFile sourceFile = _imageEditingContext.SupportingFileService.CreateSupportingFile(emoticon.Id + emoticon.FileExtension, emoticonStream);
            ImageFileData sourceFileData = new ImageFileData(sourceFile, emoticon.Bitmap.Width, emoticon.Bitmap.Height, ImageFileRelationship.Source);

            BlogPostImageData imageData = new BlogPostImageData(sourceFileData);

            if (GlobalEditorOptions.SupportsFeature(ContentEditorFeature.ShadowImageForDrafts))
                imageData.InitShadowFile(_imageEditingContext.SupportingFileService);

            emoticonStream.Seek(0, SeekOrigin.Begin);
            ISupportingFile inlineFile = _imageEditingContext.SupportingFileService.CreateSupportingFile(emoticon.Id + emoticon.FileExtension, emoticonStream);
            imageData.InlineImageFile = new ImageFileData(inlineFile, emoticon.Bitmap.Width, emoticon.Bitmap.Height, ImageFileRelationship.Inline);

            _imageEditingContext.ImageList.AddImage(imageData);

            SetInlineImageUri(emoticon, imageData.InlineImageFile.Uri);

            return imageData.InlineImageFile.Uri;
        }
示例#28
0
        private static List <NewImageInfo> ScanImages(IBlogPostHtmlEditor currentEditor, IEditorAccount editorAccount, ContentEditor editor, bool useDefaultTargetSettings)
        {
            List <NewImageInfo> newImages = new List <NewImageInfo>();

            ApplicationPerformance.ClearEvent("InsertImage");
            ApplicationPerformance.StartEvent("InsertImage");

            using (new WaitCursor())
            {
                IHTMLElement2 postBodyElement = (IHTMLElement2)((BlogPostHtmlEditorControl)currentEditor).PostBodyElement;
                if (postBodyElement != null)
                {
                    foreach (IHTMLElement imgElement in postBodyElement.getElementsByTagName("img"))
                    {
                        string imageSrc = imgElement.getAttribute("srcDelay", 2) as string;

                        if (string.IsNullOrEmpty(imageSrc))
                        {
                            imageSrc = imgElement.getAttribute("src", 2) as string;
                        }

                        // WinLive 96840 - Copying and pasting images within shared canvas should persist source
                        // decorator settings. "wlCopySrcUrl" is inserted while copy/pasting within canvas.
                        bool   copyDecoratorSettings = false;
                        string attributeCopySrcUrl   = imgElement.getAttribute("wlCopySrcUrl", 2) as string;
                        if (!string.IsNullOrEmpty(attributeCopySrcUrl))
                        {
                            copyDecoratorSettings = true;
                            imgElement.removeAttribute("wlCopySrcUrl", 0);
                        }

                        // Check if we need to apply default values for image decorators
                        bool   applyDefaultDecorator       = true;
                        string attributeNoDefaultDecorator = imgElement.getAttribute("wlNoDefaultDecorator", 2) as string;
                        if (!string.IsNullOrEmpty(attributeNoDefaultDecorator) && string.Compare(attributeNoDefaultDecorator, "TRUE", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            applyDefaultDecorator = false;
                            imgElement.removeAttribute("wlNoDefaultDecorator", 0);
                        }

                        string applyDefaultMargins = imgElement.getAttribute("wlApplyDefaultMargins", 2) as string;
                        if (!String.IsNullOrEmpty(applyDefaultMargins))
                        {
                            DefaultImageSettings defaultImageSettings = new DefaultImageSettings(editorAccount.Id, editor.DecoratorsManager);
                            MarginStyle          defaultMargin        = defaultImageSettings.GetDefaultImageMargin();
                            // Now apply it to the image
                            imgElement.style.marginTop    = String.Format(CultureInfo.InvariantCulture, "{0} px", defaultMargin.Top);
                            imgElement.style.marginLeft   = String.Format(CultureInfo.InvariantCulture, "{0} px", defaultMargin.Left);
                            imgElement.style.marginBottom = String.Format(CultureInfo.InvariantCulture, "{0} px", defaultMargin.Bottom);
                            imgElement.style.marginRight  = String.Format(CultureInfo.InvariantCulture, "{0} px", defaultMargin.Right);
                            imgElement.removeAttribute("wlApplyDefaultMargins", 0);
                        }

                        if ((UrlHelper.IsFileUrl(imageSrc) || IsFullPath(imageSrc)) && !ContentSourceManager.IsSmartContent(imgElement))
                        {
                            Uri imageSrcUri = new Uri(imageSrc);
                            try
                            {
                                BlogPostImageData imageData = BlogPostImageDataList.LookupImageDataByInlineUri(editor.ImageList, imageSrcUri);
                                Emoticon          emoticon  = EmoticonsManager.GetEmoticon(imgElement);
                                if (imageData == null && emoticon != null)
                                {
                                    // This is usually an emoticon copy/paste and needs to be cleaned up.
                                    Uri inlineImageUri = editor.EmoticonsManager.GetInlineImageUri(emoticon);
                                    imgElement.setAttribute("src", UrlHelper.SafeToAbsoluteUri(inlineImageUri), 0);
                                }
                                else if (imageData == null)
                                {
                                    if (!File.Exists(imageSrcUri.LocalPath))
                                    {
                                        throw new FileNotFoundException(imageSrcUri.LocalPath);
                                    }

                                    // WinLive 188841: Manually attach the behavior so that the image cannot be selected or resized while its loading.
                                    DisabledImageElementBehavior disabledImageBehavior = new DisabledImageElementBehavior(editor.IHtmlEditorComponentContext);
                                    disabledImageBehavior.AttachToElement(imgElement);

                                    Size sourceImageSize                      = ImageUtils.GetImageSize(imageSrcUri.LocalPath);
                                    ImagePropertiesInfo  imageInfo            = new ImagePropertiesInfo(imageSrcUri, sourceImageSize, new ImageDecoratorsList(editor.DecoratorsManager, new BlogPostSettingsBag()));
                                    DefaultImageSettings defaultImageSettings = new DefaultImageSettings(editorAccount.Id, editor.DecoratorsManager);

                                    // Make sure this is set because some imageInfo properties depend on it.
                                    imageInfo.ImgElement = imgElement;

                                    bool isMetafile = ImageHelper2.IsMetafile(imageSrcUri.LocalPath);
                                    ImageClassification imgClass = ImageHelper2.Classify(imageSrcUri.LocalPath);
                                    if (!isMetafile && ((imgClass & ImageClassification.AnimatedGif) != ImageClassification.AnimatedGif))
                                    {
                                        // WinLive 96840 - Copying and pasting images within shared canvas should persist source
                                        // decorator settings.
                                        if (copyDecoratorSettings)
                                        {
                                            // Try to look up the original copied source image.
                                            BlogPostImageData imageDataOriginal = BlogPostImageDataList.LookupImageDataByInlineUri(editor.ImageList, new Uri(attributeCopySrcUrl));
                                            if (imageDataOriginal != null && imageDataOriginal.GetImageSourceFile() != null)
                                            {
                                                // We have the original image reference, so lets make a clone of it.
                                                BlogPostSettingsBag originalBag            = (BlogPostSettingsBag)imageDataOriginal.ImageDecoratorSettings.Clone();
                                                ImageDecoratorsList originalDecoratorsList = new ImageDecoratorsList(editor.DecoratorsManager, originalBag);

                                                ImageFileData originalImageFileData = imageDataOriginal.GetImageSourceFile();
                                                Size          originalImageSize     = new Size(originalImageFileData.Width, originalImageFileData.Height);
                                                imageInfo = new ImagePropertiesInfo(originalImageFileData.Uri, originalImageSize, originalDecoratorsList);
                                            }
                                            else
                                            {
                                                // There are probably decorators applied to the image, but in a different editor so we can't access them.
                                                // We probably don't want to apply any decorators to this image, so apply blank decorators and load the
                                                // image as full size so it looks like it did before.
                                                imageInfo.ImageDecorators     = defaultImageSettings.LoadBlankLocalImageDecoratorsList();
                                                imageInfo.InlineImageSizeName = ImageSizeName.Full;
                                            }
                                        }
                                        else if (applyDefaultDecorator)
                                        {
                                            imageInfo.ImageDecorators = defaultImageSettings.LoadDefaultImageDecoratorsList();

                                            if ((imgClass & ImageClassification.TransparentGif) == ImageClassification.TransparentGif)
                                            {
                                                imageInfo.ImageDecorators.AddDecorator(NoBorderDecorator.Id);
                                            }
                                        }
                                        else
                                        {
                                            // Don't use default values for decorators
                                            imageInfo.ImageDecorators     = defaultImageSettings.LoadBlankLocalImageDecoratorsList();
                                            imageInfo.InlineImageSizeName = ImageSizeName.Full;
                                        }
                                    }
                                    else
                                    {
                                        ImageDecoratorsList decorators = new ImageDecoratorsList(editor.DecoratorsManager, new BlogPostSettingsBag());
                                        decorators.AddDecorator(editor.DecoratorsManager.GetDefaultRemoteImageDecorators());
                                        imageInfo.ImageDecorators = decorators;
                                    }

                                    imageInfo.ImgElement       = imgElement;
                                    imageInfo.DhtmlImageViewer = editorAccount.EditorOptions.DhtmlImageViewer;

                                    //discover the "natural" target settings from the DOM
                                    string linkTargetUrl = imageInfo.LinkTargetUrl;
                                    if (linkTargetUrl == imageSrc)
                                    {
                                        imageInfo.LinkTarget = LinkTargetType.IMAGE;
                                    }
                                    else if (!String.IsNullOrEmpty(linkTargetUrl) && !UrlHelper.IsFileUrl(linkTargetUrl))
                                    {
                                        imageInfo.LinkTarget = LinkTargetType.URL;
                                    }
                                    else
                                    {
                                        imageInfo.LinkTarget = LinkTargetType.NONE;
                                    }

                                    if (useDefaultTargetSettings)
                                    {
                                        if (!GlobalEditorOptions.SupportsFeature(ContentEditorFeature.SupportsImageClickThroughs) && imageInfo.DefaultLinkTarget == LinkTargetType.IMAGE)
                                        {
                                            imageInfo.DefaultLinkTarget = LinkTargetType.NONE;
                                        }

                                        if (imageInfo.LinkTarget == LinkTargetType.NONE)
                                        {
                                            imageInfo.LinkTarget = imageInfo.DefaultLinkTarget;
                                        }
                                        if (imageInfo.DefaultLinkOptions.ShowInNewWindow)
                                        {
                                            imageInfo.LinkOptions.ShowInNewWindow = true;
                                        }
                                        imageInfo.LinkOptions.UseImageViewer       = imageInfo.DefaultLinkOptions.UseImageViewer;
                                        imageInfo.LinkOptions.ImageViewerGroupName = imageInfo.DefaultLinkOptions.ImageViewerGroupName;
                                    }

                                    Size defaultImageSize = defaultImageSettings.GetDefaultInlineImageSize();
                                    Size initialSize      = ImageUtils.GetScaledImageSize(defaultImageSize.Width, defaultImageSize.Height, sourceImageSize);

                                    // add to list of new images
                                    newImages.Add(new NewImageInfo(imageInfo, imgElement, initialSize, disabledImageBehavior));
                                }
                                else
                                {
                                    // When switching blogs, try to adapt image viewer settings according to the blog settings.

                                    ImagePropertiesInfo imageInfo = new ImagePropertiesInfo(imageSrcUri, ImageUtils.GetImageSize(imageSrcUri.LocalPath), new ImageDecoratorsList(editor.DecoratorsManager, imageData.ImageDecoratorSettings));
                                    imageInfo.ImgElement = imgElement;
                                    // Make sure the new crop and tilt decorators get loaded
                                    imageInfo.ImageDecorators.MergeDecorators(DefaultImageSettings.GetImplicitLocalImageDecorators());
                                    string viewer = imageInfo.DhtmlImageViewer;
                                    if (viewer != editorAccount.EditorOptions.DhtmlImageViewer)
                                    {
                                        imageInfo.DhtmlImageViewer = editorAccount.EditorOptions.DhtmlImageViewer;
                                        imageInfo.LinkOptions      = imageInfo.DefaultLinkOptions;
                                    }

                                    // If the image is an emoticon, update the EmoticonsManager with the image's uri so that duplicate emoticons can point to the same file.
                                    if (emoticon != null)
                                    {
                                        editor.EmoticonsManager.SetInlineImageUri(emoticon, imageData.InlineImageFile.Uri);
                                    }
                                }
                            }
                            catch (ArgumentException e)
                            {
                                Trace.WriteLine("Could not initialize image: " + imageSrc);
                                Trace.WriteLine(e.ToString());
                            }
                            catch (DirectoryNotFoundException)
                            {
                                Debug.WriteLine("Image file does not exist: " + imageSrc);
                            }
                            catch (FileNotFoundException)
                            {
                                Debug.WriteLine("Image file does not exist: " + imageSrc);
                            }
                            catch (IOException e)
                            {
                                Debug.WriteLine("Image file cannot be read: " + imageSrc + " " + e);
                                DisplayMessage.Show(MessageId.FileInUse, imageSrc);
                            }
                        }
                    }
                }
            }

            return(newImages);
        }
示例#29
0
    public override Texture2D LoadImageAt(int index, bool Alpha)
    {
        if (ImageFileDataLoaded == false)
        {
            if (!LoadImageFile())
            {
                return(base.LoadImageAt(index));
            }
        }
        else
        {
            if (ImageCache[index] != null)
            {
                return(ImageCache[index]);
            }
        }


        long imageOffset = DataLoader.getValAtAddress(ImageFileData, (index * 4) + 3, 32);

        if (imageOffset >= ImageFileData.GetUpperBound(0))
        {                //Image out of range
            return(base.LoadImageAt(index));
        }
        int     BitMapWidth  = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 1, 8);
        int     BitMapHeight = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 2, 8);
        int     datalen;
        Palette auxpal;
        int     auxPalIndex;

        char[] imgNibbles;
        char[] outputImg;


        switch (DataLoader.getValAtAddress(ImageFileData, imageOffset, 8)) //File type
        {
        case 0x4:                                                          //8 bit uncompressed
        {
            imageOffset       = imageOffset + 5;
            ImageCache[index] = Image(ImageFileData, imageOffset, BitMapWidth, BitMapHeight, "name_goes_here", GameWorldController.instance.palLoader.Palettes[PaletteNo], Alpha);
            return(ImageCache[index]);
        }

        case 0x8:        //4 bit run-length
        {
            if (!useOverrideAuxPalIndex)
            {
                auxPalIndex = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 3, 8);
            }
            else
            {
                auxPalIndex = OverrideAuxPalIndex;
            }
            datalen     = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 4, 16);
            imgNibbles  = new char[Mathf.Max(BitMapWidth * BitMapHeight * 2, (datalen + 5) * 2)];
            imageOffset = imageOffset + 6;                              //Start of raw data.
            copyNibbles(ImageFileData, ref imgNibbles, datalen, imageOffset);
            auxpal    = PaletteLoader.LoadAuxilaryPal(Loader.BasePath + AuxPalPath, GameWorldController.instance.palLoader.Palettes[PaletteNo], auxPalIndex);
            outputImg = DecodeRLEBitmap(imgNibbles, datalen, BitMapWidth, BitMapHeight, 4);
            //rawOut.texture= Image(outputImg,0, BitMapWidth, BitMapHeight,"name_goes_here",auxpal,true);
            ImageCache[index] = Image(outputImg, 0, BitMapWidth, BitMapHeight, "name_goes_here", auxpal, Alpha);
            return(ImageCache[index]);
        }

        case 0xA:        //4 bit uncompressed//Same as above???
        {
            if (!useOverrideAuxPalIndex)
            {
                auxPalIndex = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 3, 8);
            }
            else
            {
                auxPalIndex = OverrideAuxPalIndex;
            }
            datalen     = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 4, 16);
            imgNibbles  = new char[Mathf.Max(BitMapWidth * BitMapHeight * 2, (5 + datalen) * 2)];
            imageOffset = imageOffset + 6;                              //Start of raw data.
            copyNibbles(ImageFileData, ref imgNibbles, datalen, imageOffset);
            auxpal            = PaletteLoader.LoadAuxilaryPal(BasePath + AuxPalPath, GameWorldController.instance.palLoader.Palettes[PaletteNo], auxPalIndex);
            ImageCache[index] = Image(imgNibbles, 0, BitMapWidth, BitMapHeight, "name_goes_here", auxpal, Alpha);
            return(ImageCache[index]);
        }

        //break;
        default:
            //Check to see if the file is panels.gr
            if (pathGR[FileToLoad].ToUpper().EndsWith("PANELS.GR"))
            {
                BitMapWidth  = 83;                         //getValAtAddress(textureFile, textureOffset + 1, 8);
                BitMapHeight = 114;                        // getValAtAddress(textureFile, textureOffset + 2, 8);
                if (_RES == "UW2")
                {
                    BitMapWidth  = 79;
                    BitMapHeight = 112;
                }
                imageOffset       = DataLoader.getValAtAddress(ImageFileData, (index * 4) + 3, 32);
                ImageCache[index] = Image(ImageFileData, imageOffset, BitMapWidth, BitMapHeight, "name_goes_here", GameWorldController.instance.palLoader.Palettes[PaletteNo], Alpha);
                return(ImageCache[index]);
            }
            break;
        }

        return(new Texture2D(2, 2));
    }