I'm still trying to figure out how to do this simple task with WPF.
I need to draw a black circle using WPF and generate an image file. (gif or
png)
Any help is greatly appreciated.
Tem
I used the following but it resulted in a blank file. I cannot figure out
what is wrong with it.
RenderTargetBitmap rtb = new RenderTargetBitmap(200, 200, 96, 96,
PixelFormats.Pbgra32);
Ellipse cir = new Ellipse();
cir.Height = 50;
cir.Width = 50;
cir.Stroke = Brushes.Black;
cir.StrokeThickness = 1.0;
rtb.Render(cir);
PngBitmapEncoder png = new PngBitmapEncoder();
png.Frames.Add(BitmapFrame.Create(rtb));
using (Stream fs= File.Create("test.png"))
{
png.Save(fs);
} 5 2847
"Tem" <te*****@yahoo.comwrote in message
news:u9*************@TK2MSFTNGP06.phx.gbl...
I'm still trying to figure out how to do this simple task with WPF.
I need to draw a black circle using WPF and generate an image file. (gif
or png)
Any help is greatly appreciated.
Tem
I used the following but it resulted in a blank file. I cannot figure out
what is wrong with it.
RenderTargetBitmap rtb = new RenderTargetBitmap(200, 200, 96, 96,
PixelFormats.Pbgra32);
Ellipse cir = new Ellipse();
cir.Height = 50;
cir.Width = 50;
cir.Stroke = Brushes.Black;
cir.StrokeThickness = 1.0;
rtb.Render(cir);
PngBitmapEncoder png = new PngBitmapEncoder();
png.Frames.Add(BitmapFrame.Create(rtb));
using (Stream fs= File.Create("test.png"))
{
png.Save(fs);
}
You are missing something like:
cir.Arrange(new Rect(new Size(50, 50)));
Note that you might get quicker answers when you consult (and post) to the
msdn WPF forum first http://forums.microsoft.com/MSDN/Sho...D=119&SiteID=1
Willy.
Thank you so much, I got it to work.
Another simple question:
I need to add another circle, slightly smaller, 45 in diameter to the same
image. the final image should be a ring.
What would be the command to add another shape?
Here's my code:
RenderTargetBitmap rtb = new RenderTargetBitmap(200, 200, 96,
96,PixelFormats.Pbgra32);
Ellipse cir = new Ellipse();
cir.Height = 50;
cir.Width = 50;
cir.Stroke = Brushes.Black;
cir.StrokeThickness = 1.0;
cir.Arrange(new Rect(new Size(50, 50)));
rtb.Render(cir);
PngBitmapEncoder png = new PngBitmapEncoder();
png.Frames.Add(BitmapFrame.Create(rtb));
using (Stream fs= File.Create("test.png"))
{
png.Save(fs);
}
"Tem" <te*****@yahoo.comwrote in message
news:OK**************@TK2MSFTNGP05.phx.gbl...
Thank you so much, I got it to work.
Another simple question:
I need to add another circle, slightly smaller, 45 in diameter to the same
image. the final image should be a ring.
What would be the command to add another shape?
Here's my code:
RenderTargetBitmap rtb = new RenderTargetBitmap(200, 200, 96,
96,PixelFormats.Pbgra32);
Ellipse cir = new Ellipse();
cir.Height = 50;
cir.Width = 50;
cir.Stroke = Brushes.Black;
cir.StrokeThickness = 1.0;
cir.Arrange(new Rect(new Size(50, 50)));
rtb.Render(cir);
PngBitmapEncoder png = new PngBitmapEncoder();
png.Frames.Add(BitmapFrame.Create(rtb));
using (Stream fs= File.Create("test.png"))
{
png.Save(fs);
}
Draw a new ellipse inside the first one and render.
...
rtb.Render(cir);
cir.Height = 45;
cir.Width = 45;
cir.Arrange(new Rect(new Size(50, 50)));
rtb.Render(cir);
....
Willy. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Uncle_Alias |
last post by:
I would like use some of the GD image functions, so I ran a couple of
short scripts to see if it worked, such as:
<?php
/* Create a red square */
$image = imagecreate(200, 200);
$colorRed =...
|
by: Rithish |
last post by:
I have a set of images on a server. I want to pick these from the
database without creating a
temporary file on the server; and also have some text alongwith it.
Something like,
...
|
by: Doug R |
last post by:
I'm trying to create an anti-automation feature to prevent scripts
from running reports on our website by requiring users to enter a code
from an image (like Yahoo e-mail sign-up, or Network...
|
by: jaapkramer |
last post by:
I have a page with 641 images in it. Each image can be clicked with as
result that the image source will be changed. For this the images need
to have a unique ID. But to do this manually for 641 is...
|
by: Paolo Pignatelli |
last post by:
I am trying to get an output/file like this (below) in an XML file
(MyXmlFile.xml) (which I will use for a slide show)
--
<gallery timer="3" order="sequential" fadetime="2" looping="yes"...
|
by: Karthik Seetharaman |
last post by:
I have to aspx pages default.aspx and imagegen.aspx
default.aspx has an image webcontrol whose imageurl property is set to
imagegen.aspx. imagegen.aspx generates a bitmap image and writes it to...
|
by: John.Arthur |
last post by:
Hello,
I need to create picture containing number that I will write in the
picture. I need it to show it to the users of my application and they
will write the number in a textBox, so this is to...
|
by: Mark Harrison |
last post by:
I would like to try and build a queuing mechanism on top of Postgresql.
Imagine an application where a large number of processes generate images
and queue up thumbnail requests. A smaller number...
|
by: e_matthes |
last post by:
Hello everyone,
I'm trying to make a class that will generate images. I can get it to
work if the class and the instance of the class is in the same file.
However, I can't get it to work if I...
|
by: shotokan99 |
last post by:
hi,
i wanted to accomplish these task:
1. from that webservice get a certain set of strings from the header
2. next, generate the image.
and these 2 steps will be done at the same time.
to...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |