Robert Russell
Top achievements
Rank 1
Robert Russell
asked on 05 Aug 2011, 06:24 PM
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?
Is this a bug in the RadBinaryImage control? Or, is there a property that I missed that denotes image type?
8 Answers, 1 is accepted
0
Andrew
Top achievements
Rank 1
Iron
Iron
answered on 11 Aug 2011, 05:29 AM
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?
Is there any way we can get transparent GIF files to render as they are supposed to through the RadBinaryImage?
0
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:
Otherwise, the transformations applied to crop or fit the image are not compatible with transparent backgrounds.
Regards,
Tsvetina
the Telerik team
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.
0
Robert Russell
Top achievements
Rank 1
answered on 11 Aug 2011, 03:37 PM
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:
Edit: Apparently I can't attach a .cs file, so here's the MyBinaryImage class:
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
}
0
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
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.
0
Richard
Top achievements
Rank 1
answered on 13 Sep 2011, 01:19 PM
I am also facing the same problem. Any solution ?
0
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.
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.
0
Richard
Top achievements
Rank 1
answered on 15 Sep 2011, 07:45 AM
I was using Image Transformation. But even after removing it , the results are same.
0
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
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