Image Manipulation (Watermarking, Resizing and Thumbnails)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leonard Challis

    #1

    Image Manipulation (Watermarking, Resizing and Thumbnails)

    Good morning everyone

    I am currently doing quite a large project in VB6 and ACCESS for college,
    for a Photographers company assignment. I am posting here to see if anyone
    has any advice on what I might want to try to counter the problems I seem to
    be facing...

    The only area of the project I am struggling on is the graphical side.
    Basically, I need to take in a load of large photographs, create a thumbnail
    for each, create a preview size for each, and then watermark the preview
    size. The thumbnail size and preview size images will later be uploaded to
    the web server so customers can view them.

    Currently I am using two different methods for the different tasks. For
    resizing, including preview size and thumbnails I have been using FreeImage
    which seems to work pretty well actually. It hasn't been easy to find (free)
    watermarking .DLLs/modules/activeX controls though, and I am currently using
    something I found on a forum, which basically takes two pictures boxes and
    loops through each pixel and combines the two picture boxes creating the
    watermark. It is very hit and miss.. but it is kind of the best thing I can
    use right now.

    What I was wondering is does anyone know of a good method of doing the tasks
    I want without having to include more than one or two .DLLs or something
    like a control that supports all these features. There are loads out there I
    have found on Google, but being a student I can't afford the huge price
    tags! Any suggestions or ideas would be welcome and thanks for your time.

    Lenny Challis

    FYI: Here is some examples of the code I am using/referencing to make my
    own:

    _______________ ____
    Watermarking
    _______________ ____
    Option Explicit

    ' Return (A * clr1 + (255-A) * clr2)\256.
    Private Function CombineColors(B yVal clr1 As OLE_COLOR, ByVal clr2 As
    OLE_COLOR, ByVal A As Byte) As OLE_COLOR
    Dim r1 As Long
    Dim g1 As Long
    Dim b1 As Long
    Dim r2 As Long
    Dim g2 As Long
    Dim b2 As Long

    b1 = Int(clr1 / 65536)
    g1 = Int((clr1 - (65536 * b1)) / 256)
    r1 = clr1 - ((b1 * 65536) + (g1 * 256))

    b2 = Int(clr2 / 65536)
    g2 = Int((clr2 - (65536 * b2)) / 256)
    r2 = clr2 - ((b2 * 65536) + (g2 * 256))

    r1 = (A * r1 + (255 - A) * r2) \ 256
    g1 = (A * g1 + (255 - A) * g2) \ 256
    b1 = (A * b1 + (255 - A) * b2) \ 256

    CombineColors = r1 + 256 * g1 + 65536 * b1
    End Function

    Private Sub Command1_Click( )

    DrawWatermark Picture1, picBackground, (picBackground. ScaleWidth / 2 -
    Picture1.ScaleW idth / 2), (picBackground. ScaleHeight / 2 -
    Picture1.ScaleH eight / 2)

    End Sub

    ' Copy the watermark image over the result image.
    Private Sub DrawWatermark(B yVal wm_pic As PictureBox, ByVal bg_pic As
    PictureBox, ByVal x As Integer, ByVal y As Integer)
    Const ALPHA As Byte = 128
    Dim transparent As OLE_COLOR
    Dim wm_clr As OLE_COLOR
    Dim bg_clr As OLE_COLOR
    Dim new_clr As OLE_COLOR
    Dim px As Integer
    Dim py As Integer

    ' Get the transparent color.
    transparent = wm_pic.Point(0, 0)

    ' Combine the images.
    wm_pic.ScaleMod e = vbPixels
    bg_pic.ScaleMod e = vbPixels
    For py = 0 To wm_pic.ScaleHei ght - 1
    For px = 0 To wm_pic.ScaleWid th - 1
    wm_clr = wm_pic.Point(px , py)
    If wm_clr <> transparent Then
    bg_clr = bg_pic.Point(x + px, y + py)
    new_clr = CombineColors(w m_clr, bg_clr, ALPHA)
    bg_pic.PSet (x + px, y + py), new_clr
    End If
    Next px
    Next py
    End Sub

    Private Sub Form_Load()

    End Sub


Working...