Board index » delphi » Image 'watermark'

Image 'watermark'

I am trying to 'watermark' images by superimposing a font on top of
the image, filled with a lightened version of the image behind the
font.  Can anyone provide any pointers as to how I might go about
doing this?

Thanks,

Noel

 

Re:Image 'watermark'


You need to create a background bitmap.
 set the pixelformat := pf24bit;
 deside on a mask color. lets say its $00FFFFFF; because most don't use
white for their art work in fonts.
 you rease the image with this mask color by setting the brush.color.
 fill the background with this color.
then apply your fonts, images ect on this layer and not using the mask
color.
when you are ready to apply this as the water mark you can then
scan the image converting it into a B&W image except for the brush
color.
reading the RGB values and converting them as so.
 Sum := Trunc(R :=  R*0.30+ (G :=G*0.59) +( B := B*0.11);
If Sum = $00FFFFFF then Dec(Sum); // make sure you don't have Brush
color.
the reset the pixel that you just read.
  canvas.Pixels[x,y] := RGB(Sum,Sum,Sum);
this will give you a nice B&W shade that now can be used as a scale for
your
color shades in your image.
when your ready you scan your color image and water Mark image.
 use one of the 2 values which will all be the same from the mask image
R,G or b
as the scaling factor   R/255 for example * each R,G,B of your color
image to
change the intensity..
etc..
 i am sure you get the idea..
Quote
Noel wrote:
> I am trying to 'watermark' images by superimposing a font on top of
> the image, filled with a lightened version of the image behind the
> font.  Can anyone provide any pointers as to how I might go about
> doing this?

> Thanks,

> Noel

Re:Image 'watermark'


Hi Noel,

What you need to do is to produce a temporary bitmap that contains your
desired text and then alpha blend your main image with that bitmap ... it's
not that hard to do and I do suspect that there'll be some components around
that might do this ... what you need to do is to scan and darken each pixel
in accordance with the luminance of your temporary bitmap ... white = no
change ... black = black ... a good site to look at is :

http://www.efg2.com/

there's lots of good stuff on image manipulation ... alpha blending too ...
and you'll need to look at using ScanLine ... Pixels[x, y] will work but
it'd be very slow ...

Andrew

Re:Image 'watermark'


This would be the same as drawing a white font onto the image with an alpha
value which is not 255 but for instance 20 or 30.

You can use either:
- GDI+
- Graphics32 www.g32.org

The last one is my fav.

If you don't want to use either of these libs you can also just use TBitmap.
Something along these steps

Load Bitmap1:
- this is the original bitmap with your image
- Set it to pf24Bit

Create Bitmap2:
- set it to the size of Bitmap1,

Add Text to bitmap2, with Color = clBlack

Create Bitmap3:
- set it to the size of Bitmap1
- set it to Pixelformat := pf24Bit
- loop through rows, columns
  "if Bitmap2.Pixels[Row, Col] = clBlack then"
  - Set the color of Bitmap3.Pixels[Row, Col] to a lightened version of
Bitmap1
  "else"
  - Bitmap3.Pixels[Row, Col] := Bitmap1.Pixels[Row, Col]

You can change the above "Pixels" references with a faster scanline method.
This requires a bit more coding but is a lot faster.

Creating a lightened pixel can be done by changing each of the three
components (Red, Green, Blue) like this:

New := (Old * (255 - Alpha) + 255 * Alpha) div 255;

When Alpha = 255 -> You will have a complete white pixel
When Alpha = 0   -> You will have the original color.

I haven't tested this. You could also look into conversion of the RGB color
to a HSV model, then changing V and then converting back.

Hope that helps,

Nils Haeck
www.simdesign.nl
www.abc-view.com

Quote
"Noel" <z...@oisin.demon.co.uk> wrote in message

news:th0k6vg7r23lj8v91k7bvcunmfk435q39q@4ax.com...
Quote
> I am trying to 'watermark' images by superimposing a font on top of
> the image, filled with a lightened version of the image behind the
> font.  Can anyone provide any pointers as to how I might go about
> doing this?

> Thanks,

> Noel

Re:Image 'watermark'


You can also use PNG (Portable Network Graphics) as source of your Watermark
and then copy its contents to selected BMP/JPeG,... programmatically. As it
is known, PNG does support Alpha transparency. Take a look at
http://pngdelphi.sourceforge.net for free PNG code for Delphi. Best, Miha.

Quote
"Noel" <z...@oisin.demon.co.uk> wrote in message

news:th0k6vg7r23lj8v91k7bvcunmfk435q39q@4ax.com...
Quote
> I am trying to 'watermark' images by superimposing a font on top of
> the image, filled with a lightened version of the image behind the
> font.  Can anyone provide any pointers as to how I might go about
> doing this?

> Thanks,

> Noel

Re:Image 'watermark'


On Sat, 08 Mar 2003 14:47:48 +0000, Noel <z...@oisin.demon.co.uk>
wrote:

Quote
>I am trying to 'watermark' images by superimposing a font on top of
>the image, filled with a lightened version of the image behind the
>font.  Can anyone provide any pointers as to how I might go about
>doing this?

>Thanks,

>Noel

1. Measure your text area, copy that much of image and draw text to an
equal size bitmap.
2. Copyrect an equal size part of your original image.
3. Blend both bitmaps using the Tween example.
4. Draw that bitmap back onto original image.

Other Threads