Click here to Skip to main content
15,913,903 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: No Resources Pin
Luc Pattyn4-May-10 7:57
sitebuilderLuc Pattyn4-May-10 7:57 
AnswerRe: No Resources Pin
Abhinav S4-May-10 7:50
Abhinav S4-May-10 7:50 
GeneralRe: No Resources Pin
#realJSOP4-May-10 7:52
professional#realJSOP4-May-10 7:52 
QuestionDynamic Image binding Pin
Sunil P V4-May-10 6:22
Sunil P V4-May-10 6:22 
AnswerRe: Dynamic Image binding Pin
Leung Yat Chun5-May-10 11:25
Leung Yat Chun5-May-10 11:25 
GeneralRe: Dynamic Image binding Pin
Sunil P V5-May-10 22:21
Sunil P V5-May-10 22:21 
GeneralRe: Dynamic Image binding Pin
Leung Yat Chun5-May-10 22:59
Leung Yat Chun5-May-10 22:59 
GeneralRe: Dynamic Image binding Pin
Sunil P V6-May-10 20:01
Sunil P V6-May-10 20:01 
GeneralRe: Dynamic Image binding Pin
Leung Yat Chun6-May-10 23:16
Leung Yat Chun6-May-10 23:16 
GeneralRe: Dynamic Image binding Pin
Sunil P V7-May-10 5:13
Sunil P V7-May-10 5:13 
AnswerRe: Dynamic Image binding Pin
Abhinav S6-May-10 20:17
Abhinav S6-May-10 20:17 
Questionmultiple big images on canvas in WPF - rendering problems Pin
gruberdominik4-May-10 3:50
gruberdominik4-May-10 3:50 
AnswerRe: multiple big images on canvas in WPF - rendering problems [modified] Pin
Insincere Dave5-May-10 8:52
Insincere Dave5-May-10 8:52 
GeneralRe: multiple big images on canvas in WPF - rendering problems Pin
gruberdominik10-May-10 22:36
gruberdominik10-May-10 22:36 
QuestionHelp Needed Pin
Xerox44-May-10 0:21
professionalXerox44-May-10 0:21 
AnswerRe: Help Needed Pin
Pete O'Hanlon4-May-10 1:23
mvePete O'Hanlon4-May-10 1:23 
Questionrandom image appear Pin
yuripon3-May-10 15:32
yuripon3-May-10 15:32 
AnswerRe: random image appear Pin
Kunal Chowdhury «IN»9-May-10 0:40
professionalKunal Chowdhury «IN»9-May-10 0:40 
QuestionWPF Browser Application Error - System.ArgumentException: Value does not fall within the expected range. Pin
Polymorpher3-May-10 14:38
Polymorpher3-May-10 14:38 
AnswerRe: WPF Browser Application Error - System.ArgumentException: Value does not fall within the expected range. Pin
prabhu_thil23-Nov-10 7:16
prabhu_thil23-Nov-10 7:16 
QuestionWriteableBitmap problem Pin
#realJSOP3-May-10 2:54
professional#realJSOP3-May-10 2:54 
Using SL3/VS2008:

I'm (still) trying to render text on a bitmap. Tim Yen suggested using WriteableBitmap, and even that doesn't seem to work for me. I've tried it two different ways:

Label label = new Label();
label.Style = this.Resources["TitleBaseStyle"] as Style;
label.Content = "WHMC";
<br />
WriteableBitmap bmp = new WriteableBitmap(60, 60);
bmp.Render(label, new TranslateTransform()); // I also tried a null Transform here
bmp.Invalidate();
<br />
Image image = new Image();
image.HorizontalAlignment = HorizontalAlignment.Center;
image.VerticalAlignment = VerticalAlignment.Center;
image.Width=60;
image.Height=60;
image.Source = bmp;
this.testImage.Child = image;


...and...

Label label = new Label();
label.Style = this.Resources["TitleBaseStyle"] as Style;
label.Content = "WHMC";
<br />
WriteableBitmap bmp = new WriteableBitmap(label, new TranslateTransform());
<br />
Image image = new Image();
image.HorizontalAlignment = HorizontalAlignment.Center;
image.VerticalAlignment = VerticalAlignment.Center;
image.Width=60;
image.Height=60;
image.Source = bmp;
this.testImage.Child = image;


In the interest of completeness, here's the label's custom style:

<Style x:Key="TitleBaseStyle" TargetType="dataInput:Label">
	<Setter Property="Width" Value="60" />
	<Setter Property="Height" Value="30" />
	<Setter Property="Background" Value="Black" />
	<Setter Property="Foreground" Value="White" />
	<Setter Property="FontSize" Value="17" />
	<Setter Property="Padding" Value="0" />
	<Setter Property="HorizontalAlignment" Value="Center" />
	<Setter Property="HorizontalContentAlignment" Value="Center" />
	<Setter Property="VerticalAlignment" Value="Center" />
	<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>


...and here's the container for the image:

<Border x:Name="testImage" BorderBrush="Black" Background="Red" BorderThickness="1" Margin="10"/>


Neither method results in an Image with anything visible in it (all the pixels in the WriteableBitmap object are null). This is driving me insane. What the hell am I doing wrong?

Just to make sure the label was being created as expected, I also did this, and it is displayed as expected:

Label label = new Label();
label.Style = this.Resources["TitleBaseStyle"] as Style;
label.Content = "WHMC";

this.testImage.Child = label;


I'm at a total loss...

EDIT ==================

I downloaded the WriteableBitmapEx assembly from codeplex because it contains a Clear(Color) method (like the GDI Bitmap class does). If I don't call bmp.Render(label), the image does in fact get displayed. If I put the bmp.Render(label) back into the code, the image does NOT display.

Side note: If I call bmp.Clear(Color.Transparent) (and remove the Render(label) line), the rendered image has a whiteground, despite the Image object being placed in a red-filled Border container.

WTF?
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

AnswerRe: WriteableBitmap problem Pin
Rama Krishna Vavilala3-May-10 4:34
Rama Krishna Vavilala3-May-10 4:34 
GeneralRe: WriteableBitmap problem Pin
#realJSOP3-May-10 5:06
professional#realJSOP3-May-10 5:06 
AnswerRe: WriteableBitmap problem Pin
42774803-May-10 10:27
42774803-May-10 10:27 
GeneralRe: WriteableBitmap problem Pin
42774803-May-10 11:11
42774803-May-10 11:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.