469,646 Members | 1,731 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

Adding an logo-image/tekst to an existing image.

On my webpage I am making I want that if users view any image in my gallery
a small logo/tekst will appear in the image.
I know it's possible but I haven't got a clue how to get a logo or tekst on
a image.

Does someone got an example or somewhere I can read more about it except the
MSDN?

thx in advance.

Richard
Nov 18 '05 #1
6 1736
On Tue, 15 Jun 2004 20:20:10 +0200, "Richard" <ri*****@nospam.com>
wrote:
On my webpage I am making I want that if users view any image in my gallery
a small logo/tekst will appear in the image.
I know it's possible but I haven't got a clue how to get a logo or tekst on
a image.

Does someone got an example or somewhere I can read more about it except the
MSDN?

thx in advance.

Richard


you can use System.Drawing.Image. you will have to read about this
class as well as the Bitmap class in order to be able to combine an
image with another.

-Adam
Nov 18 '05 #2
Hi Richard,

As for how to manipulating image in asp.net web application and add some
mark/logo in it so as to protect them from linked by other user or sites.
Here are my suggestions:

First of all, Adam's suggestion that use the GDI+ api under the
System.Drawing.Image namespace is quite reasonable and it has provided
sufficient interfaces for manipulating image. And as for add our custom
flag/mark in the image in our web app when they're requested by other
users, gerenally we need to do the following steps:

1. Define a HttpHandler to service all the image request and use GDI+ code
to manipulate the image and output it to user.

2. After built the HttpHandler , register it in web.config of the asp.net
web application. And don't forget to set the ISAPI extension in IIS's
virtual dir ,we have to mapp the image extension(we want to processed by
our handler) to the aspnet_isapi.dll.

In addition, here are some tech articles discussing manipulating image in
asp.net

#Watermark Website Images At Runtime
http://www.codeproject.com/aspnet/httpImageHandler.asp

#HTTP Handlers for Images in ASP.NET
http://www.c-sharpcorner.com/Code/20...sForImages.asp

#Image Generation Service for ASP.NET 1.1
http://msdn.microsoft.com/msdnmag/is...e/default.aspx

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
As Steven said.
Here is a piece of code I used to implement such a http handler. The
handler is adding some text to the image. You should remove the security
check...

public class AddJpegCopyrightHttpHandler : IHttpHandler
{
const string COPYRIGHT_NOTICE = " a copyright notice";
private SolidBrush brush = new SolidBrush(Color.Gray);

public AddJpegCopyrightHttpHandler()
{
}

#region Implementation of IHttpHandler
public void ProcessRequest(System.Web.HttpContext context)
{
string filePath = context.Request.MapPath(context.Request.FilePath);

PhotoGaleryPrincipal user = System.Web.HttpContext.Current.User as
PhotoGaleryPrincipal;
bool isPrivate = filePath.IndexOf("\\PrivateGalery\\") != -1;
if( (user == null && isPrivate) || (user != null &&
!user.AlowPrivateAccess && isPrivate) )
{
throw new System.Security.SecurityException("The picture you
requested is in a private galery. You must be logged in and have access
to private galeries to access this picture.");
}

Bitmap photo = (Bitmap)Bitmap.FromFile(filePath);
if( photo.Width > 200 && photo.Height > 200 )
{
Graphics g = Graphics.FromImage(photo);
Font font = new Font("verdana", photo.Height / 100);
SizeF size = g.MeasureString(COPYRIGHT_NOTICE, font);
g.DrawString(COPYRIGHT_NOTICE, font, brush, photo.Width -
size.Width - 10, photo.Height - size.Height * 1.2F);
g.Dispose();
}
context.Response.ContentType = "image/jpeg";
photo.Save(context.Response.OutputStream, ImageFormat.Jpeg);
}

public bool IsReusable
{
get
{
return true;
}
}
#endregion
}

hope this helps
____________________
www.bloomfield.as.ro
Nov 18 '05 #4
Hi Richard,

Have you had a chance to check out the suggestions in the former replies or
have you got any further ideas on this issue? If there're anything else we
can help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #5
the HTTPHandler stuff is still a bit out of my league. atm I am reading more
about it and
from all I have seen I like what you can do with it so its a much know for
me.

I still have some issue's with putting another logo on an existing image but
the text works for me now.
I guess I just have to read some more and play a bit with it.

Anyway, thx for the help,

Richard

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> schreef in bericht
news:QH**************@cpmsftngxa10.phx.gbl...
Hi Richard,

Have you had a chance to check out the suggestions in the former replies or have you got any further ideas on this issue? If there're anything else we
can help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #6
Hello Richard,

Steven is OOF these two days. :) However, if there is any more question on it, please feel free to post in the group. We will follow up with you.

Thanks very much for participating the community.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Xah Lee | last post: by
15 posts views Thread by Albretch | last post: by
5 posts views Thread by Andrew Thompson | last post: by
3 posts views Thread by Uffe Kousgaard | last post: by
4 posts views Thread by Xah Lee | last post: by
11 posts views Thread by Xah Lee | last post: by
1 post views Thread by colmkav | last post: by
1 post views Thread by timsamshuijzen | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.