public void BindDatalist() { //DataSet dsProductMasterCartList = CProductMasterServices.ProductMasteCartList(Convert.ToInt32(LblCategoryId.Text),Convert.ToInt32(LblSubCategoryId.Text),int.Parse(Request.QueryString["Coscat"].ToString())); DataSet dsProductMasterCartList = CProductMasterServices.ProductMasteCartList(Convert.ToInt32(LblCategoryId.Text), Convert.ToInt32(LblSubCategoryId.Text), Convert.ToInt32(LblCosubcategoryId.Text)); // DataSet dsProductMasterCartList = CCartMasterrServices.CartList(17, 30, 11); ImageDataList.DataSource = dsProductMasterCartList; ImageDataList.DataBind(); }
public static AnimationChain FromGif(string fileName, string contentManagerName) { if (FileManager.IsRelative(fileName)) { fileName = FileManager.RelativeDirectory + fileName; } if (FlatRedBallServices.IsLoaded <AnimationChain>(fileName, contentManagerName)) { return(FlatRedBallServices.GetNonDisposable <AnimationChain>(fileName, contentManagerName).Clone()); } ImageDataList imageDataList = GifLoader.GetImageDataList(fileName); int numberOfFrames = imageDataList.Count; AnimationChain animationChain = new AnimationChain(numberOfFrames); for (int i = 0; i < numberOfFrames; i++) { // We assume GIFs are for 2D games that don't need mipmaps. Could change this later // if needed const bool generateMipmaps = false; Texture2D texture2D = imageDataList[i].ToTexture2D(generateMipmaps, FlatRedBallServices.GraphicsDevice); texture2D.Name = fileName + i.ToString(); if (i >= imageDataList.FrameTimes.Count) { const double defaultFrameTime = .1; animationChain.Add( new AnimationFrame( texture2D, (float)defaultFrameTime)); } else { animationChain.Add( new AnimationFrame( texture2D, (float)imageDataList.FrameTimes[i])); } FlatRedBallServices.AddDisposable(texture2D.Name, texture2D, contentManagerName); } // Don't dispose the anything because it's part of the // content manager. animationChain.ParentGifFileName = fileName; animationChain.Name = FileManager.RemovePath(fileName); return(animationChain); }
protected void PopulateDataList() { //ImagePath , Cust_id Query = "select * from Customer where Gender = '" + GenderDropDownList.SelectedItem.Value + "'"; dt = cc.GetData(Query); if (dt.Rows.Count == 0) { ErrorLabel.Visible = true; ErrorLabel.Text = "No Data Available"; } else { ErrorLabel.Visible = false; ErrorLabel.Text = ""; ImageDataList.DataSource = dt; ImageDataList.DataBind(); } }
public static ImageDataList GetImageDataList(string gifFileName) { ImageDataList imageDatas = new ImageDataList(); #if XBOX360 || SILVERLIGHT if (gifFileName.StartsWith(@".\") || gifFileName.StartsWith(@"./")) { gifFileName = gifFileName.Substring(2); } #endif #if SILVERLIGHT || WINDOWS_8 using (Stream stream = FileManager.GetStreamForFile(gifFileName)) #else using (FileStream stream = System.IO.File.OpenRead(gifFileName)) #endif { mGifInfo = new GifInfo(); mGifInfo.DelayTimes = new List<short>(); BinaryReader reader = new BinaryReader(stream); #region header // Example: GIF89a byte[] buffer = reader.ReadBytes(6); // set the header here char[] charArray = new char[buffer.Length]; for (int i = 0; i < buffer.Length; i++) { charArray[i] = (char)buffer[i]; } mGifInfo.Header = new string(charArray); #endregion #region Width/Height mGifInfo.Width = reader.ReadInt16(); mGifInfo.Height = reader.ReadInt16(); #endregion #region Packed information // The packed byte has the following info: // Bits 0-2 Size of the Global Color Table // Bit 3 Color Table Sort Flag // Bits 4-6 Color Resolution // Bit 7 Global Color Table Flag Byte packedByte = reader.ReadByte(); int sizeOfGlobalColorTable = (7 & packedByte); mGifInfo.NumberOfColorEntries = 1 * (1 << (sizeOfGlobalColorTable + 1)); mGifInfo.HasGlobalColorTable = (128 & packedByte) != 0; #endregion #region background color reader.ReadByte(); #endregion #region default aspect ratio reader.ReadByte(); #endregion TryReadGlobalColorTable(reader); byte separator = reader.ReadByte(); while (separator != 0x3b) // Extension { switch(separator) { #region Extensions case 0x21: Byte label = reader.ReadByte(); switch (label) { case 0xf9: ReadGraphicsControlExtension(reader); break; case 0xff: ReadApplicationExtensionBlock(reader); break; case 0xfe: ReadCommonExtensionBlock(reader); break; } break; #endregion #region Image Data case 0x2c: ReadImageDescriptor(reader); Color[] color = new Color[mGifInfo.Width * mGifInfo.Height]; int transparentIndex = mGifInfo.TransparentIndex; #region Interlaced if (mGifInfo.IsInterlaced) { int i = 0; for (int pass = 0; pass < 4; ++pass) { int row = 0; int increment = 0; switch (pass) { case 0: row = 0; increment = 8; break; case 1: row = 4; increment = 8; break; case 2: row = 2; increment = 4; break; case 3: row = 1; increment = 2; break; } for (; row < mGifInfo.Height; row += increment) { for (int col = 0; col < mGifInfo.Width; ++col) { int position = (row * mGifInfo.Width) + col; byte index = mUncompressedColorIndexBuffer[i++]; byte alpha = 255; if (mGifInfo.HasTransparency && index == transparentIndex) alpha = 0; #if FRB_XNA || SILVERLIGHT || WINDOWS_PHONE color[position] = new Color( (byte)mGifInfo.PaletteInfo.Entries[index].R, (byte)mGifInfo.PaletteInfo.Entries[index].G, (byte)mGifInfo.PaletteInfo.Entries[index].B, (byte)alpha); #elif FRB_MDX color[position] = Color.FromArgb( alpha, (byte)mGifInfo.PaletteInfo.Entries[index].R, (byte)mGifInfo.PaletteInfo.Entries[index].G, (byte)mGifInfo.PaletteInfo.Entries[index].B); #endif } } } } #endregion else { #region NonInterlaced for (int i = 0; i < mGifInfo.PaletteInfo.Entries.Length; i++) { mGifInfo.PaletteInfo.Entries[transparentIndex].A = 255; } if (mGifInfo.HasTransparency) { mGifInfo.PaletteInfo.Entries[transparentIndex].A = 0; } int x = 0; int y = 0; int colorIndex; for (int i = 0; i < mUncompressedColorIndexBuffer.Count; i++) { byte index = mUncompressedColorIndexBuffer[i]; // Let's see if we can avoid an if statement x = mGifInfo.CurrentBlockLeft + i % mGifInfo.CurrentBlockWidth; y = mGifInfo.CurrentBlockTop + i / mGifInfo.CurrentBlockWidth; colorIndex = x + y * mGifInfo.Width; #if FRB_XNA || SILVERLIGHT || WINDOWS_PHONE color[colorIndex] = new Color( (byte)mGifInfo.PaletteInfo.Entries[index].R, (byte)mGifInfo.PaletteInfo.Entries[index].G, (byte)mGifInfo.PaletteInfo.Entries[index].B, (byte)mGifInfo.PaletteInfo.Entries[index].A); #elif FRB_MDX color[colorIndex] = Color.FromArgb( (byte)mGifInfo.PaletteInfo.Entries[index].A, (byte)mGifInfo.PaletteInfo.Entries[index].R, (byte)mGifInfo.PaletteInfo.Entries[index].G, (byte)mGifInfo.PaletteInfo.Entries[index].B); #endif } #endregion } ImageData imageData = new ImageData( mGifInfo.Width, mGifInfo.Height, color); imageDatas.Add(imageData); mUncompressedColorIndexBuffer.Clear(); break; #endregion #region End of file case 0x3b: // end of file break; #endregion } separator = reader.ReadByte(); } } // Fill the imageDatas with the frame times foreach (short s in mGifInfo.DelayTimes) { imageDatas.FrameTimes.Add(s / 100.0); } return imageDatas; }
Texture2D LoadTexture2D(string assetName, string extension) { Texture2D loadedAsset = null; if (Renderer.Graphics == null) { throw new NullReferenceException("The Renderer's Graphics is null. Call FlatRedBallServices.Initialize before attempting to load any textures"); } switch (extension.ToLowerInvariant()) { case "bmp": { ImageData bmp = FlatRedBall.IO.BmpLoader.GetPixelData(assetName); bmp.Replace(FlatRedBallServices.GraphicsOptions.TextureLoadingColorKey, Color.Transparent); Texture2D texture = bmp.ToTexture2D(); //new Texture2D(FlatRedBallServices.GraphicsDevice, bmp.Width, bmp.Height, 0, TextureUsage.None, SurfaceFormat.Color); //texture.SetData<Color>(bmp.Data); texture.Name = assetName; loadedAsset = texture; break; } case "png": case "jpg": bool useFrbPngLoader = false; if (useFrbPngLoader) { #if MONOGAME throw new NotImplementedException(); #else ImageData png = FlatRedBall.IO.PngLoader.GetPixelData(assetName); Texture2D texture = png.ToTexture2D(); texture.Name = assetName; loadedAsset = texture; #endif } else { Texture2D texture = LoadTextureFromFile(assetName); texture.Name = assetName; loadedAsset = texture; } break; case "dds": case "dib": case "hdr": case "pfm": case "ppm": case "tga": { throw new NotImplementedException("The following texture format is not supported" + extension + ". We recommend using the .png format"); //break; } case "gif": { #if MONOGAME throw new NotImplementedException(); #else ImageDataList imageDataList = GifLoader.GetImageDataList(assetName); int numberOfFrames = imageDataList.Count; if (imageDataList.Count == 0) { throw new InvalidOperationException("The gif file " + assetName + " has no frames"); } else { Texture2D texture2D = imageDataList[0].ToTexture2D(); texture2D.Name = assetName; loadedAsset = texture2D; } break; #endif } //break; default: throw new ArgumentException("FlatRedBall does not support the " + extension + " file type passed for loading a Texture2D"); //break; } return(loadedAsset); }
public static ImageDataList GetImageDataList(string gifFileName) { ImageDataList imageDatas = new ImageDataList(); #if XBOX360 || SILVERLIGHT if (gifFileName.StartsWith(@".\") || gifFileName.StartsWith(@"./")) { gifFileName = gifFileName.Substring(2); } #endif #if SILVERLIGHT || WINDOWS_8 using (Stream stream = FileManager.GetStreamForFile(gifFileName)) #else using (FileStream stream = System.IO.File.OpenRead(gifFileName)) #endif { mGifInfo = new GifInfo(); mGifInfo.DelayTimes = new List <short>(); BinaryReader reader = new BinaryReader(stream); #region header // Example: GIF89a byte[] buffer = reader.ReadBytes(6); // set the header here char[] charArray = new char[buffer.Length]; for (int i = 0; i < buffer.Length; i++) { charArray[i] = (char)buffer[i]; } mGifInfo.Header = new string(charArray); #endregion #region Width/Height mGifInfo.Width = reader.ReadInt16(); mGifInfo.Height = reader.ReadInt16(); #endregion #region Packed information // The packed byte has the following info: // Bits 0-2 Size of the Global Color Table // Bit 3 Color Table Sort Flag // Bits 4-6 Color Resolution // Bit 7 Global Color Table Flag Byte packedByte = reader.ReadByte(); int sizeOfGlobalColorTable = (7 & packedByte); mGifInfo.NumberOfColorEntries = 1 * (1 << (sizeOfGlobalColorTable + 1)); mGifInfo.HasGlobalColorTable = (128 & packedByte) != 0; #endregion #region background color reader.ReadByte(); #endregion #region default aspect ratio reader.ReadByte(); #endregion TryReadGlobalColorTable(reader); byte separator = reader.ReadByte(); while (separator != 0x3b) // Extension { switch (separator) { #region Extensions case 0x21: Byte label = reader.ReadByte(); switch (label) { case 0xf9: ReadGraphicsControlExtension(reader); break; case 0xff: ReadApplicationExtensionBlock(reader); break; case 0xfe: ReadCommonExtensionBlock(reader); break; } break; #endregion #region Image Data case 0x2c: ReadImageDescriptor(reader); Color[] color = new Color[mGifInfo.Width * mGifInfo.Height]; int transparentIndex = mGifInfo.TransparentIndex; #region Interlaced if (mGifInfo.IsInterlaced) { int i = 0; for (int pass = 0; pass < 4; ++pass) { int row = 0; int increment = 0; switch (pass) { case 0: row = 0; increment = 8; break; case 1: row = 4; increment = 8; break; case 2: row = 2; increment = 4; break; case 3: row = 1; increment = 2; break; } for (; row < mGifInfo.Height; row += increment) { for (int col = 0; col < mGifInfo.Width; ++col) { int position = (row * mGifInfo.Width) + col; byte index = mUncompressedColorIndexBuffer[i++]; byte alpha = 255; if (mGifInfo.HasTransparency && index == transparentIndex) { alpha = 0; } #if FRB_XNA || SILVERLIGHT || WINDOWS_PHONE color[position] = new Color( (byte)mGifInfo.PaletteInfo.Entries[index].R, (byte)mGifInfo.PaletteInfo.Entries[index].G, (byte)mGifInfo.PaletteInfo.Entries[index].B, (byte)alpha); #elif FRB_MDX color[position] = Color.FromArgb( alpha, (byte)mGifInfo.PaletteInfo.Entries[index].R, (byte)mGifInfo.PaletteInfo.Entries[index].G, (byte)mGifInfo.PaletteInfo.Entries[index].B); #endif } } } } #endregion else { #region NonInterlaced for (int i = 0; i < mGifInfo.PaletteInfo.Entries.Length; i++) { mGifInfo.PaletteInfo.Entries[transparentIndex].A = 255; } if (mGifInfo.HasTransparency) { mGifInfo.PaletteInfo.Entries[transparentIndex].A = 0; } int x = 0; int y = 0; int colorIndex; for (int i = 0; i < mUncompressedColorIndexBuffer.Count; i++) { byte index = mUncompressedColorIndexBuffer[i]; // Let's see if we can avoid an if statement x = mGifInfo.CurrentBlockLeft + i % mGifInfo.CurrentBlockWidth; y = mGifInfo.CurrentBlockTop + i / mGifInfo.CurrentBlockWidth; colorIndex = x + y * mGifInfo.Width; #if FRB_XNA || SILVERLIGHT || WINDOWS_PHONE color[colorIndex] = new Color( (byte)mGifInfo.PaletteInfo.Entries[index].R, (byte)mGifInfo.PaletteInfo.Entries[index].G, (byte)mGifInfo.PaletteInfo.Entries[index].B, (byte)mGifInfo.PaletteInfo.Entries[index].A); #elif FRB_MDX color[colorIndex] = Color.FromArgb( (byte)mGifInfo.PaletteInfo.Entries[index].A, (byte)mGifInfo.PaletteInfo.Entries[index].R, (byte)mGifInfo.PaletteInfo.Entries[index].G, (byte)mGifInfo.PaletteInfo.Entries[index].B); #endif } #endregion } ImageData imageData = new ImageData( mGifInfo.Width, mGifInfo.Height, color); imageDatas.Add(imageData); mUncompressedColorIndexBuffer.Clear(); break; #endregion #region End of file case 0x3b: // end of file break; #endregion } separator = reader.ReadByte(); } } // Fill the imageDatas with the frame times foreach (short s in mGifInfo.DelayTimes) { imageDatas.FrameTimes.Add(s / 100.0); } return(imageDatas); }