|
I'd suggest reading my image processing articles for info on how to access the pixels of a bitmap, then work out what sort of watermark you want to add. Assuming you don't just want to add a bitmap in the corner or something simple.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
A method like this may do the job, if you just want to add text to the image: (you'll need to include the System.Drawing reference and namespace)
Bitmap AddWaterMark(Bitmap uploadedBitmap)
{
Bitmap newBitmap = new Bitmap(uploadedBitmap);
Graphics g = Graphics.FromImage(newBitmap);
g.RotateTransform(45); // Angle of text
g.DrawString("Watermark Text",
new Font("Arial", 12f),
new SolidBrush(Color.FromArgb(100, Color.Black)), // the 100 is for transparency (0 = invisible, 255 = opaque)
new Point(100,100));
return newBitmap;
}
|
|
|
|
|
Thanks Bob!!!
Tried the given code. now that we have the graphics object which is updated. How to apply this to my image, to what should i assign the returned bitmapfile? how to save my final image with the watermark?
Thank you
Gautham
|
|
|
|
|
Hi Bob!
Sorry for the other question! It worked thanks a lot.
The only thing i have to think about is to place the text at a specific location irrespective the size of the image.
Thank You.
Gautham
|
|
|
|
|
New and improved Method to help you place the text perfectly diagonal and centered. All you have to decide on is the font and transparency.
Bitmap AddWaterMark(Bitmap uploadedBitmap)
{
Bitmap newBitmap = new Bitmap(uploadedBitmap);
Graphics g = Graphics.FromImage(newBitmap);
// This StringFormat will position the text so that
// the Point in the DrawString() method below is in
// the centre of the string rather than top-left
StringFormat strFormat = new StringFormat();
strFormat.Alignment = StringAlignment.Center;
strFormat.LineAlignment = StringAlignment.Center;
// Here we use a bit of Trigonometry to calculate the angle
// so that we can draw the string perfectly diagonally based
// passed bitmap dimensions
double tangent = (double)newBitmap.Height / (double)newBitmap.Width;
double angle = Math.Atan(tangent) * (180 / Math.PI);
// Here we adjust the position so that we place the text half-way
// along the hypotenuse (diagonal line through bitmap)
double halfHyponenuse = Math.Sqrt((newBitmap.Width * newBitmap.Width) +
(newBitmap.Height * newBitmap.Height)) / 2;
g.RotateTransform((float)angle);
g.DrawString("Watermark Text",
new Font("Arial", 12f),
new SolidBrush(Color.FromArgb(200, Color.Black)),
new Point((int)halfHyponenuse, 0),
strFormat);
return newBitmap;
}
-- modified at 9:09 Tuesday 23rd January, 2007
|
|
|
|
|
Hi,
Can any one help me to build a listview control where i can add two check box in the last right column of listview.
|
|
|
|
|
Even though its possible, its not simple... Why dont you u use datagrid? Its easy to do that with datagrid....
|
|
|
|
|
Hi,
I am looking for some tutorial in c# object oriented programming.
Can anyone share some good links.
Have a good day
|
|
|
|
|
OOP is the same, no matter what the language. I'm sure google is teeming with information, but I'd recommend buying a good book and working through it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Could you please recommend one or two.
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Hi,
Can any one help me to build a listview control where i can add two check box in the last right column of listview.
Please help me.
THanks
Biswabhusan
|
|
|
|
|
Hi,
I have a class that has a string attribute.
I set this attribute to " " (a space) and serialize the instance to an xml file. When I deserialize that instance the value of that string attribute is null, not space..
How can I do that??
public class MyClass
{
private string str;
public string Str
{
get{return str;}
set{str = value;}
}
}
[STAThread]
static void Main(string[] args)
{
MyClass mycls = new MyClass();
mycls.Str = " ";
TextWriter tw = new StreamWriter("str.xml");
XmlSerializer sr = new XmlSerializer(typeof(MyClass));
sr.Serialize(tw, mycls);
tw.Close();
FileStream fs = new FileStream("str.xml", FileMode.Open);
XmlSerializer sr2 = new XmlSerializer(typeof(MyClass));
MyClass mycls2 = (MyClass)sr2.Deserialize(fs);
fs.Close();
Console.WriteLine("***" + mycls2.Str + "***" );
}
output: ******
|
|
|
|
|
Try this out!!!
. . .
FileStream fs = new FileStream("str.xml", FileMode.Open);
XmlTextReader reader = new XmlTextReader(fs);
XmlSerializer sr2 = new XmlSerializer(typeof(MyClass));
MyClass mycls2 = (MyClass)sr2.Deserialize(reader);
. . .
|
|
|
|
|
Hai Guys,
Do you know how to read the attribute value of an element in xml using c# dataset and tables.
Explanation with example will be appreciated.
Thanks.
VijayaRam
|
|
|
|
|
Is there any way we can show embedded flash content in a webBrowser control? and is there any way of doing this without the flash player installed? Thanks in advance.
|
|
|
|
|
Hai Guys,
I have problem in localizing my application to some other language such as japanese, chinese,etc.
Your Ideas about implementing localisation in c# windows application is welcomed and appreciated.
VijayaRam
|
|
|
|
|
Please share your problem.
Regards,
Bhupi Bhai.
|
|
|
|
|
Hi,
To implement the localization we need to do
1) Create .resx file for each language.
2) Generate .resource file from the .resx file using resgen tool.
3) Create the ResourceManger in your application.
4) The .resx files store the language strings as key value. So read the language string using the Getstring method of ResourceManager passig key value as input parameter.
Guess this will help you.
Pani
|
|
|
|
|
Thanks for your idea,
But can you ellborate your points in details for clear understanding.
if possible can you provide Sample codes, it will be useful.
Thanks & Regards,
VijayaRam
|
|
|
|
|
our website is being hosted by some other people sir
and now i have changed write permission and i updated on the webserver
still the same problem is coming
do i need to publish my site once again and update all of the files or
only the databasse file has to replaced sir
how can i change write permission to mdb file programatically
thanking u bye
|
|
|
|
|
Hello,
I want to know how we transfer file or send file to another ..
like if client want to send file on server,, what i will do in C# for this
Thankyou
|
|
|
|
|
Have a look at the System.Net namespace.
Search on:
WebClient
HttpWebRequest
|
|
|
|
|
Hello ,
Pls clerify that which kind of transfering you would like......
bye Stateless ( HTTP )
or Statefull ( FTP ).
It's both way you can transfer file from 1 end to another end.
Keep Smiling !!!
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
Hi,
I need to pass a relativly complicated struct into a dll calling a CORBA Service which has to be written in vc6.0 and it has to contain many elements which are necessary to create an input for a service.
Unfortunately I can see only the first array element, other are ignored.
Here an example of c# code:
<br />
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]<br />
public struct MyStrStruct3<br />
{<br />
public string FirstName;<br />
public string FamilyName;<br />
public int size;<br />
}<br />
<br />
[DllImport(@"C:\Projects\CorbaLib60\Debug\CorbaLib.dll")]<br />
private static extern int TestMe(ref MyStrStruct3[] pstr);<br />
<br />
MyStrStruct3[] Names = new MyStrStruct3[2];<br />
Names[0].FamilyName = "Konieczny";<br />
Names[0].FirstName = "Marek";<br />
Names[0].size = 3;<br />
Names[1].FamilyName = "OtherName";<br />
Names[1].FirstName = "OtherFirst";<br />
Names[1].size = 2;<br />
int miki1 = TestMe(ref Names);<br />
C++ code look like this:
<br />
typedef struct _MyStruct2<br />
{<br />
char* FirstName;<br />
char* FamilyName;<br />
UINT size; <br />
} MyStruct2;<br />
<br />
<br />
int TestMe(MyStruct2* pStruct[])<br />
{ <br />
int Size = 2;<br />
<br />
for (int i=0; i<Size; i++ )<br />
{<br />
int woofie = pStruct[i]->size;<br />
char* miki = pStruct[i]->FamilyName;<br />
char* miki1 = pStruct[i]->FirstName;<br />
}<br />
return 42;<br />
}<br />
I define export :
<br />
<br />
__declspec(dllexport) int TestMe(MyStruct2* pStruct[2]);<br />
<br />
It works, but only for first element. I also have tried to pass it as
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]<br />
public struct MyStrStruct4<br />
{<br />
public MyStrStruct3[] Names;<br />
public int size;<br />
}
but it doesn't work and raise an exception.
Marek
|
|
|
|
|
hi people i want to create a reportthrough my code. i'm using VS.Net 2003.
i have already wrote some code files on a specified location through the StreamWriter class using the following code:
string filepath = File_Path + Path.DirectorySeparatorChar + "AssemblyInfo.cs";<br />
<br />
using (StreamWriter sw = new StreamWriter(filepath))
"AssemblyInfo.cs" is the name of the file that i have created.
filepath tells the location on which to create this file.
now i want to know that how i can write on an Html page that i have added to my VS project.
can anyone help me??
Regards
|
|
|
|