Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, November 18, 2010 10:31:51 AM(UTC)
lmanderson

Groups: Registered
Posts: 1


Hi all,

Let me set this up for you.  I have a website that allows a user to upload a image (typically their company logo) and we render it on a mug. 

The original vb6 code was written by my predecessor so not much of api is understood all that well.

Here is the basic process
1. Load the image
2. Detect and Remove any background (white) to make it transparent
3. Combine it with the product image based on coordinates provided.
4. Save a jpeg newly combine image.
5. DONE

Questions

1. A lot of these methods  no longer exist at least by they original names.
1a. Is there a document I've not seen that translates the old function names to new ones?
1b. Missing : ColorRes,AutoRepaint,AutoTrim,BitmapTransparentColor,BitmapPalette,SetRgnColor.

2. Even when i find the exact translation to .net, Is this still the best approach for the process described, or given 4 versions of upgrades, is there new methods I should be looking at?

And here is the code :


 '/ Combines Logo with Model Image and Watch hands (optional).
    '/ Returns path to generated image GUID (Empty string on error).
    '/ Lead Objects
    Dim imgModel As Object
    Dim imgLogo As Object
    Dim imgHands As Object
   
    '/ New Logo Dimensions
    Dim intNewLogoX As Integer
    Dim intNewLogoY As Integer
   
    '/ Local Variables
    Dim strHandsFilePath As String
    Dim strOutputFileName As String
   
    On Error GoTo Err_Handler
   
    '/ Create LEAD Image Objects
    Set imgModel = CreateObject("LEAD.LeadCtrl.130")
   
    '/ Unlock Special Lead Product Support (PDF,EPS,GIF,TIFF)
    imgModel.UnlockSupport L_SUPPORT_PDF, "xxxxx"
    imgModel.UnlockSupport L_SUPPORT_GIFLZW, "xxxxxxx"
    imgModel.UnlockSupport L_SUPPORT_TIFLZW, "xxxxxxxx"
   
    '/ Load Model Image
    imgModel.Load strModelFilePath, 24, 0, 1
    If imgModel.BitmapBits <> 24 Then
        '/ Force Color Depth to 24bit
        imgModel.ColorRes 24, CRP_NETSCAPEPALETTE, CRD_NODITHERING, 0
    End If
       
    '/ Create LEAD Image Objects
    Set imgLogo = CreateObject("LEAD.LeadCtrl.130")
    imgLogo.AutoRepaint = False
    '/ Unlock Special Lead Product Support (PDF,EPS,GIF,TIFF)
    imgLogo.UnlockSupport L_SUPPORT_PDF, "xxxxx"
    imgLogo.UnlockSupport L_SUPPORT_GIFLZW, "xxxxxxxx"
    imgLogo.UnlockSupport L_SUPPORT_TIFLZW, "xxxxxxxxx"
   
    '\ Load Logo Image
    imgLogo.Load strLogoFilePath, 24, 0, 1
    If imgLogo.BitmapBits <> 24 Then
        '/ Force Color Depth to 24bit
        imgLogo.ColorRes 24, CRP_NETSCAPEPALETTE, CRD_NODITHERING, 0
    End If
    imgLogo.AutoTrim 0
   
    ' Detemine Logo Tranparent Color (If Supported)
    Dim value As Long
    value = imgLogo.BitmapTransparentColor
    If value >= 16777216 Then
        '\ Determine Pallete Index
        Dim palletteIndex As Long
        palletteIndex = value - 16777216
        imgLogo.BitmapTransparentColor = imgLogo.BitmapPalette(palletteIndex)
    Else
        imgLogo.BitmapTransparentColor = value
    End If
   
    '/ Set Transparent Background
    If value <> 0 Then
        imgLogo.SetRgnColor value, L_RGN_SETNOT
    Else
        imgLogo.SetRgnColor RGB(255, 255, 255), L_RGN_SETNOT
    End If
    imgLogo.PaintRgnOnly = True
    imgLogo.ForceRepaint

   
    '/ Calculate Max Size of Logo while keeping aspect ratio
    If imgLogo.RgnWidth / oActiveImprint.MaxCanvasX > imgLogo.RgnHeight / oActiveImprint.MaxCanvasY Then
        '/ Width Limited
        intNewLogoX = oActiveImprint.MaxCanvasX
        intNewLogoY = imgLogo.RgnHeight * (intNewLogoX / imgLogo.RgnWidth)
    Else
        '/ Height Limited
        intNewLogoY = oActiveImprint.MaxCanvasY
        intNewLogoX = imgLogo.RgnWidth * (intNewLogoY / imgLogo.RgnHeight)
    End If
   
      
    '/ Resize Logo
    imgLogo.Size intNewLogoX, intNewLogoY, RESIZE_RESAMPLE
           
    '/ Apply LogoColorMode Tranformations
    Select Case ColorModeID
        Case COLOR_MODE_FULL
            '/ Keep full color logo (don't fill)
        Case Else
            '/ Fixed Color Mode
            imgLogo.Fill lngLogoColor
    End Select
    imgLogo.ForceRepaint
   
    '/ Combine Model & Logo image, Centering logo on imprint area
    imgModel.Combine _
        oActiveImprint.OffsetX + (oActiveImprint.MaxCanvasX - intNewLogoX) / 2, _
        oActiveImprint.OffsetY + (oActiveImprint.MaxCanvasY - intNewLogoY) / 2, _
        intNewLogoX, _
        intNewLogoY, _
        imgLogo.Bitmap, _
        0, _
        0, _
        CB_OP_ADD + CB_DST_0 + CB_SRC_NOP
   
  
   
    '/ Generate GUID
    strOutputFileName = General.GetGUID() & ".jpg"
   
    '/ Save & Return file name
    imgModel.Save g_strOutputPath & "Temp\" & strOutputFileName, FILE_JFIF, 24, 15, SAVE_OVERWRITE




 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Sunday, November 21, 2010 3:50:04 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

Was thanked: 1 time(s) in 1 post(s)

There are many differences between the details of LEADTOOLS ActiveX v13 and LEADTOOLS .Net classes.
If you need to check the new LEADTOOLS .Net classes, please refer to the LEADTOOLS v17 .Net documentation.

About the equivalent .Net classes that you need to use, you need to use the following .Net classes:
- ColorRes => ColorResolutionCommand Class
- AutoRepaint: You don't need to worry about it because you're not doing repeated, lengthy processing that would be affected by repainting.
- AutoTrim => AutoCropCommand Class
- BitmapTransparentColor  => RasterImage.TransparentColor Property
- BitmapPalette => RasterImage.GetPalette and RasterImage.SetPalette
- SetRgnColor => RasterImage.AddColorToRegion Method

Also, you will need to get updated unlock PDF keys from our sales team because the old keys do not work with the new toolkit, and you will no longer require TIFLZW and GIF unlock keys because they are now supported without the need for any key.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.173 seconds.