Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.visual.basic    |    MS Visual Basic discussions, NOT dot-net    |    10,840 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 9,235 of 10,840    |
|    Leonard Challis to All    |
|    Image Manipulation (Watermarking, Resizi    |
|    23 Feb 05 11:39:01    |
      From: ned@challis2000.fsnet.co.uk              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(ByVal 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.ScaleWidth / 2), (picBackground.ScaleHeight / 2 -       Picture1.ScaleHeight / 2)              End Sub              ' Copy the watermark image over the result image.       Private Sub DrawWatermark(ByVal 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.ScaleMode = vbPixels        bg_pic.ScaleMode = vbPixels        For py = 0 To wm_pic.ScaleHeight - 1        For px = 0 To wm_pic.ScaleWidth - 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(wm_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              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca