Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > BinaryImage > Transparent GIF Backgrounds Are Rendering

Not answered Transparent GIF Backgrounds Are Rendering

Feed from this thread
  • Posted on Aug 5, 2011 (permalink)

    I am using a RadBinaryImage to display images that have been previously uploaded into our database by dynamically setting its DataValue property.  While the control successfully renders the byte[] as an image, it fails to correctly render transparent gif colors as transparent.  For example:  Instead of rendering this transparent gif with transparent background, the RadBinaryImage control renders the gif like this.

    Is this a bug in the RadBinaryImage control?  Or, is there a property that I missed that denotes image type?

    Reply

  • Andrew avatar

    Posted on Aug 11, 2011 (permalink)

    I don't have an answer - I'm just saying "ME TOO!", I've run into exactly the same problem.

    Is there any way we can get transparent GIF files to render as they are supposed to through the RadBinaryImage? 

    Reply

  • Tsvetina Tsvetina admin's avatar

    Posted on Aug 11, 2011 (permalink)

    Hello,

    I assume you are using image transformations with transparent .gif files. This scenario is not supported. If you want to keep the transparent background of the image, you should not have any image transformations applied:
    <telerik:RadBinaryImage runat="server" Width="150px" Height="150px" ResizeMode="None"
         TabIndex="10" ID="imgClassified" AlternateText="Thumbnail" ImageUrl="~/Images/nopreview.gif" />

    Otherwise, the transformations applied to crop or fit the image are not compatible with transparent backgrounds.

    Regards,
    Tsvetina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

    Reply

  • Posted on Aug 11, 2011 (permalink)

    Hi,

    I am actually working with the RadBinaryImage in custom server controls, rather than in the html directly.  I took away from the sample html tag you posted that I needed to set the ResizeMode property to none.  However, that did not change anything.  Transparent gif backgrounds are still rendering.

    I've attached my sample class along with the following sample declaration to provide more context on how I am using the RadBinaryImage control:

    MyBinaryImage img = new MyBinaryImage()
    {
        ImageID = imageID
        , ResizeMode = BinaryImageResizeMode.None  // Added due to your post
    };
    this.Controls.Add(img);

    Edit:  Apparently I can't attach a .cs file, so here's the MyBinaryImage class:
    [ToolboxData("<{0}:MyBinaryImage runat=server />")]
    public class MyBinaryImage : RadBinaryImage
    {
        #region Class Objects
        #region Properties
        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue(-1)]
        public int ImageID
        {
            get
            {
                object temp = ViewState[this.ID + "_ImageID"];
                return (temp == null ? -1 : (int)temp);
            }
            set
            {
                ViewState[this.ID + "_ImageID"] = value;
                if (value != -1)
                    SetImage();
            }
        }
        #endregion
        #endregion
     
        #region Class Methods
        private void SetImage()
        {
            // Local Variables
            DataSet imageData = null;
            DataRow imageRow = null;
     
            // Get image info
            using (ContentHelper contentLink = new ContentHelper())
                imageData = contentLink.GetImage(ImageID);
            imageRow = (CommonLibrary.IsDataSetEmpty(imageData) ? null : imageData.Tables[0].Rows[0]);
     
            // Set image content, if obtained
            if (imageRow != null)
            {
                DataValue = (Convert.IsDBNull(imageRow["MyField"]) ? null : (byte[])imageRow["MyField"]);
                ResizeMode = BinaryImageResizeMode.None;    // Added due to your post
            }
        }
        #endregion
     
        #region Event Handlers
        protected override void OnLoad(EventArgs e)
        {
            // Perform base OnLoad
            base.OnLoad(e);
     
            // Set image content, if id specified
            if (ImageID != -1)
                SetImage();
        }
        #endregion
    }

    Reply

  • Tsvetina Tsvetina admin's avatar

    Posted on Aug 16, 2011 (permalink)

    Hi Robert,

    Your code seems fine, also we are unable to reproduce the described problem. Therefore, the best option would be if you could open a formal support ticket and send us a runnable sample replicating the issue. This way we will be able to find the cause of the issue and let you know whether and how it could be fixed. Then, if you agree, we will also post the answer here for other interested members to see.

    Thank you in advance.

    All the best,
    Tsvetina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

    Reply

  • Richard avatar

    Posted on Sep 13, 2011 (permalink)

    I am also facing the same problem. Any solution ?

    Reply

  • Tsvetina Tsvetina admin's avatar

    Posted on Sep 13, 2011 (permalink)

    Hi Richard ,

    Can you confirm that you are not using any image transformations, as described in my earlier post:
    http://www.telerik.com/community/forums/aspnet-ajax/binary-image/transparent-gif-backgrounds-are-rendering.aspx#1757914

    Greetings,
    Tsvetina
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

    Reply

  • Richard avatar

    Posted on Sep 15, 2011 (permalink)

    I was using Image Transformation. But even after removing it , the results are same.

    Reply

  • Tsvetina Tsvetina admin's avatar

    Posted on Sep 15, 2011 (permalink)

    Hello Richard ,

    Can you paste the current version of your code, so that we can use it for further investigation of the problem? Thanks in advance.

    Regards,
    Tsvetina
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > BinaryImage > Transparent GIF Backgrounds Are Rendering