Search the web
Sign In
New User? Sign Up
AIL_Development · AIL Developer's Forum
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Effect_OverlayPicture   Message List  
Reply | Forward Message #31 of 125 |
Re: Effect_OverlayPicture

There's 2 ways to do it. The first is to render directly to a Form /
PictureBox / Printer / PropertyBox like this:

---------------------------------------------
Dim objAIL As cAdvancedImagery
Dim hImg As Long
Dim hImg2 As Long

' Initialize AIL
Set objAIL = New cAdvancedImagery
' Load the background image
Call objAIL.IO_LoadImage("c:\test.bmp", hImg)
' Load the foreground transparent image
Call objAIL.IO_LoadImage("c:\test111.bmp", hImg2)
' Convert the color WHITE to transparent on the foreground image
Call objAIL.Effect_SetTransparentColor(hImg2, vbWhite, 0, True)

' Make the form visible
Me.Visible = True
Me.AutoRedraw = True
' Render the background image normally
objAIL.Render_Normal hImg, Me.hDC
Me.Refresh
' Render the foreground image transparently
objAIL.Render_Alpha hImg2, Me.hDC
Me.Refresh

' Clean up
Call objAIL.IO_DestroyImage(hImg2)
Call objAIL.IO_DestroyImage(hImg)
Set objAIL = Nothing

MsgBox "Success"

---------------------------------------------
The other is to combine them in memory like this:
---------------------------------------------

Dim objAIL As cAdvancedImagery
Dim hDevCon As Long
Dim hTempImg As Long
Dim hNewBmp As Long
Dim hOldBmp As Long
Dim hImg As Long
Dim hImg2 As Long

' Initialize AIL
Set objAIL = New cAdvancedImagery
' Load the background image
Call objAIL.IO_LoadImage("c:\test.bmp", hImg)
' Load the foreground transparent image
Call objAIL.IO_LoadImage("c:\test111.bmp", hImg2)
' Convert the color WHITE to transparent on the foreground image
Call objAIL.Effect_SetTransparentColor(hImg2, vbWhite, 0, True)
' Create a temporary image to create a BITMAP from
Call objAIL.IO_CreateNew(hTempImg, objAIL.Info_Width(hImg),
objAIL.Info_Height(hImg), 32)
' Convert temp image to BITMAP
Call objAIL.Convert_ImageToBitmap(hTempImg, hNewBmp)
' Clean up temp image
Call objAIL.IO_DestroyImage(hTempImg)
' Create a memory-based Device Context (DC)
Call objAIL.MemoryDC_Create(hDevCon)
' Insert the bitmap into the memory DC (this sets the
width/height/color depth of the memory DC)
Call objAIL.MemoryDC_InsertBitmap(hDevCon, hNewBmp, hOldBmp)

' Render the background image normally
objAIL.Render_Normal hImg, hDevCon
' Render the foreground image transparently
objAIL.Render_Alpha hImg2, hDevCon

' Pull the modified image out of the memory DC by putting back the
original BITMAP
Call objAIL.MemoryDC_InsertBitmap(hDevCon, hOldBmp, hNewBmp)
' Clean up the DC (the old/original BITMAP is automatically destroyed
with the DC)
Call objAIL.MemoryDC_Destroy(hDevCon): hOldBmp = 0
' Convert the BITMAP back to an image
Call objAIL.Convert_BitmapToImage(hNewBmp, hTempImg)
' Clean up the BITMAP
Call objAIL.IO_DestroyBitmap(hNewBmp)

' Now that we have the image we want, display it for inspection
Me.Visible = True
Me.AutoRedraw = True
objAIL.Render_Normal hTempImg, Me.hDC
Me.Refresh

' Clean up
Call objAIL.IO_DestroyImage(hTempImg)
Call objAIL.IO_DestroyImage(hImg2)
Call objAIL.IO_DestroyImage(hImg)
Set objAIL = Nothing

MsgBox "Success"

---------------------------------------------

I can see that the process of overlaying images transparently is a bit
too complex... so I'm going to be adding a new function to AIL shortly
which will do all this for you (in a more efficient manner). I'll
call it "Effect_OverlayPictureEx".

- Kevin





--- In AIL_Development@yahoogroups.com, "Michael" <michael.reep@...>
wrote:
>
> I've seen the sample picstures of what AIL can do, so I know this
> has been done, atleast some way.
>
> I'm trying to use Effect_OverlayPicture, and trying to put one image
> on top of another with a transparent background (similar to the
> FreeImage Composite function).
>
> I can load an image, and use:
> Effect_SetTransparentColor (hImg, vbWhite)
> and stream that back to the browser as a PNG, and everything's cool,
> but when I do this:
>
> IO_LoadImage strPath,hImg2,IF_PNG
> Effect_SetTransparentColor hImg2,vbWhite
> Effect_OverlayPicture hImg, hImg2, 0, 0
>
> the background on the second image (hImg2) is white, no matter what.
> I have even loaded transparent GIF's and transparent PNG's into
> hImg2 and the backgrounds are still white.
>
> Any help is appreciated.
> -Michael
>





Tue Apr 17, 2007 4:17 pm

kwilson1997
Online Now Online Now
Send Email Send Email

Forward
Message #31 of 125 |
Expand Messages Author Sort by Date

I've seen the sample picstures of what AIL can do, so I know this has been done, atleast some way. I'm trying to use Effect_OverlayPicture, and trying to put...
Michael
somenon2
Offline Send Email
Apr 17, 2007
2:40 pm

There's 2 ways to do it. The first is to render directly to a Form / ... Dim objAIL As cAdvancedImagery Dim hImg As Long Dim hImg2 As Long ' Initialize...
Kevin Wilson
kwilson1997
Online Now Send Email
Apr 17, 2007
4:32 pm

I attempted to write a function (using the code you provided via method 2) so I could get it to work from ASP. It seems to work ok, but the transparency is...
michael.reep@...
somenon2
Offline Send Email
Apr 18, 2007
2:25 pm

First off, this line will create a memory leak: bOk = objAIL.Convert_To32bit(hImg2, hImg2) You must create a separate variable to hold the result from the ...
Kevin Wilson
kwilson1997
Online Now Send Email
Apr 20, 2007
12:43 am

Still didn't work, I've attached a sample of what I'm trying to do, and I've also attached the original files that I'm using to do this first: not...
michael.reep@...
somenon2
Offline Send Email
Apr 20, 2007
2:45 pm

I don't know why it's not working for you. It worked for me in my testing. Keep in mind though, I tested calling the "Effect_OverlayPictureEx" function...
Kevin Wilson
kwilson1997
Online Now Send Email
Apr 20, 2007
3:18 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help