Transparent GIF Backgrounds Are Rendering

9 posts, 0 answers
  1. Robert Russell
    Robert Russell avatar
    2 posts
    Member since:
    May 2010

    Posted 05 Aug 2011 Link to this post

    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?
  2. Andrew
    Andrew avatar
    34 posts
    Member since:
    Dec 2010

    Posted 11 Aug 2011 Link to this post

    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? 
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 11 Aug 2011 Link to this post

    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.

  5. Robert Russell
    Robert Russell avatar
    2 posts
    Member since:
    May 2010

    Posted 11 Aug 2011 Link to this post

    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
    }
  6. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 16 Aug 2011 Link to this post

    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.

  7. Richard
    Richard  avatar
    3 posts
    Member since:
    Jun 2011

    Posted 13 Sep 2011 Link to this post

    I am also facing the same problem. Any solution ?
  8. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 13 Sep 2011 Link to this post

    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.
  9. Richard
    Richard  avatar
    3 posts
    Member since:
    Jun 2011

    Posted 15 Sep 2011 Link to this post

    I was using Image Transformation. But even after removing it , the results are same.
  10. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 15 Sep 2011 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017