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