Easy Method For Adding Alpha Channel To Bitmaps
Ok. The game I am writing uses 24 bit BMPs. I am really interested in converting these to 32-bit to support alpha channeling. What is the easiest method for doing this? And once I have them converted what is the easiest method for setting the alpha channel? Is there a way to directly edit the first byte? (I think that's the one for the alpha channel). Finally, once I have a 32-bit BMP which directdraw (or directxgraphics) function is best for handling these bitmaps?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
SImple Method For Adding Bitmaps To A Menu?
I want to add a bitmap (or an icon) to a menu item, to the left of it. I've looked over many examples, most of them confuse the heck of me.... anyone got a link or code of a really simple example?
Alpha Channel Icons
Hey,
I know there has been posts about this before, but i have serahced, and they all go off topic and don't give consice answers; People start thinking that it's size there talking about and not colour depth then the story starts to lose track, etc etc.
So,
Simply what i am looking to know is:
Can you import XP style Icons into your application. Just like you can import 256 colour icons with transparency onto your form as a picture for example. But VB6 doesnt handle the alpha channel. Is there anyway to get around this? I know that if it is a form icon for example, you can use a ico file with multiple formats, which i have imported successfully due to VB using the lower qualitys icons in design time, but when running the app in XP, it uses the correct icons. But this is an icon to go on a form; It will only have on format as such (i.e. It will be a single 32x32 size icon in an ico file). May be be to do with tricking the program into it? or is there any other method.
I hope there is SOMEWAY of doing it, because XP Icons in 256 without the alpha channel look horrible and jaggy.
If anyone can help it would be great.
Thx in advance.
DirectDraw7 Alpha Channel
I was doing some looking around about Direct Draw 7 and Alpha Channels. From what I read is that you cant do alpha channeling in DD7 without either making your own draw procedure that reads the raw data, or use an outside library like vbDabl.dll. I was looking through some files I downloaded awhile ago when I was learning DD7, one popped out at me. It was a program that created alpha channel bitmaps by taking two images, one for the color and another for the alpha channels. Then it saved as an .abmp file. I was just thinking to myself "why would someone need to make surfaces with an alpha channel if you cant even use then in DD7?" I guess this is a question for the DX gurus in the forum. Is it possible somehow to use this to make an easy to use alpha channel draw procedure. It seem like I can modify the method this example used to save .abmp files to just load the image into a surface with 32bit pixel format. Then I would have to find a way to blit the new surface with its alpha channel. My guess would be that everything I read so far is correct. But I think it would be kinda cool if there were an easier way to draw alpha channel bitmaps.
32-bit Icons With Alpha Channel
I have searched to the worlds end, but cant find any updated information on this...
Can a 32-bit Icon with Alpha Channel (win xp style) be used in VB6? I know when VB6 first came out, you could not, but has anyone found a work around for this in the recent years?
Thanks!
Icons 32-bit With Alpha Channel
hi....
i trying to insert 32bit icons into my application an there was an error, "invalid picture format". what was the problem?
Color With Alpha Channel For GDI+ Drawing
I have been trying to find a function to give me a color with an alpha channel
Up till now I have been using this:
Public Function RGB2Long(R As Integer, G As Integer, B As Integer) As Long
RGB2Long = -16777216 + (RGB(B, G, R))
End Function
which works fine, but I would like to start writing with a semi transparent pen and so wanted to set the alpha componet properly.
The best i could find was MakeARGB but it seems to be a method of the color class in .net and not something that I can call directly.
Can anyone provide me with more information?
Skinned UserControl With Alpha Channel
Hey,
I've got a big question here: what would be the best way to create a skinnable usercontrol, say using png's - with translucent areas from the alpha channel showing (and updating also when changes occur) what's underneath the control ??
I got a semi functionnal code using gdi+, only very buggy.. I got the skinning part and alpha channels working, but the only workaround i found to achieve the "show what's underneath" part was to put the control's background color to transparent, and render it's content not on itself, but directly on the parent at it's actual position...
...not pretty.
I know it's probably easier to do in .Net, but i dont have it here, and i am more familiar with good ol' vb6, and besides, i'm interested in the procedure involved..
anyone has an idea on how to achieve this?
Form Background With An Alpha Channel? (.png)
Hey all (first post, yay!)
I'd like to know how to add a .png with an alpha channel to a form's background using VisualBASIC 2005 Express.
Please try and explain it as if i were a bird, because my experience in VB is quite limited.
EDIT: I've tried using a .gif image with alpha keying but it looks very aliased, and i can't have shadows, and semi-transparency and all those things you would expect from a .png
Thanks, - Dest1ny
Edited by - Dest1ny on 7/27/2007 2:41:27 AM
Removing Alpha Channel From Form Component
Hi.. I've been assigned to make a Quicktime Movie player program that can be shown in TV screen and must be shown on top of video that already playing (imagine a TV station logo animation that sits above the video and located on the topright corner of your TV)... I've been successful in making a form that loads and plays the movie, but when I tried to combine it with other video, it doesnt show anything (including the Quicktime movie) cuz it seems the whole form has alpha-channel on it so that the video renderer engine [my office use DeckLink, probably you've heard it] ignores the color information thus make the whole form turn invisible....
What I wanted to know is how to make some part of my Form come to visible or maybe we could remove the Alpha-Channel information in some part I wanted to show in the video renderer.. Please, any comment would be very appreciated...
Thanks in advance..
Directx8: How To Load And Blt A Surface With An Alpha Channel?
I want to know how to load a surface from a bitmap file with an alpha channel and blt it on to the screen. What function(s) can I use to do this, and what type of file can it be? (that is, something I can get using photoshop alpha channels) Im using directx8
Best Editor For .PNG (DirectX) Images? (Alpha Channel Support)
Hi,
I need to edit alpha channels, but I'm kind of lost how to do it. I want to apply gradient levels of alpha, via .png files. What paint program would you recommend for doing this? Thanks...
Mods: Please dont move this thread, I need help with this from other DirectX programmers. This is not a generic "which is the best paint program" question. Thanks!!
Resampling Bitmaps With Alpha
Hi
vbAccelerator has code to resample alpha bitmaps using a proportional scheme that preserves aspect ratio.
http://www.vbaccelerator.com/home/VB/Code/vbMedia/DIB_Sections/Alpha_DIBSection/article.asp
I have pared this down to the resampling part only.
In the class 'cAlphaDibSection', the argument for
Public Function AlphaResample(ByVal lNewWidth As Long) As cAlphaDibSection
as you can see takes only one parameter - the width, and resizes the height proportionally.
Does any one know of a way to use this method to create a non-proportional resampled bitmap or other code to do the same?
Transparent Bitmaps Using PaintPicture Method
I found these instructions on the NET claiming to produce
'Transparent' bitmaps.
I have followed the instructions and it doesn't work!
(no errors but just displays an ALL BLACK image)
Can someone who has done this sort of thing spot what is wrong?
Code:
In Microsoft Paint:
1. Create 3 Bitmaps (all 200X200)
- Target.bmp - this is the background picture
color bitmap all gray
- Source.bmp - this is the picture to be drawn on the target
color left 100X200 red and right 100X200 blue
- Overlay.bmp - this is source picture with the
TRANSPARENT portions WHITE
and the
NON-TRANSPARENT portions BLACK
color left 100X200 black and right 100X200 white
In VB:
1. Draw 3 PictureBoxes on a Form
2. Load the 3 pictures into PictureBoxes
- Picture1 - Target.bmp
- Picture2 - Source.bmp
- Picture3 - Overlay.bmp
3. Put the following code in Command1 Click event
Picture1.PaintPicture Picture3.Picture, 20, 20, , , , , , , _
opcode = vbMergePaint
Picture1.PaintPicture Picture2.Picture, 20, 20, , , , , , , _
opcode = vbSrcAnd
4. Run the project - Source picture placed transparently on the Target.
Adding Bitmaps To Menu Bar
How can I add bitmaps to a menu bar and how can I change the color of the selected menu item instead of just checking it???
Is it also possible to change the font or say, make BOLD the caption of the selected item.
Another Problem With Adding Bitmaps To Menus
The other problem I'm having with them (see other message) is that the bitmaps seem to disappear when I add a submenu to the original menu. Is there another modification I need for my code? The icons are stored in an image list control.
Code:
For j = 1 To 4
hSubMenu& = GetSubMenu(hMenu&, 0)
hID& = GetMenuItemID(hSubMenu&, j - 1)
'Add the bitmap
SetMenuItemBitmaps hMenu&, hID&, MF_BITMAP, _
imlMenuImageList.ListImages(j).Picture, _
imlMenuImageList.ListImages(j).Picture
Next
Adding Bitmaps To A Popup Menu???!?
I can add bitmaps to a menu easily using the example on this website, but as soon as I make the menu a popup menu, I can't get the bitmaps to show.
'// Retrieve the menu handle
lngMenuHwnd = GetMenu(Me.hwnd)
'// Get the handle of the first submenu item
lngSubHwnd = GetSubMenu(lngMenuHwnd, 0)
'// Get the menu id of the first bitmpa
lngMenuID = GetMenuItemID(lngSubHwnd, 0)
The first line works... the second line is unable to get the submenu handle, however.
Help?!?
Adding Bitmaps To The Menu- What I Am Doing Wrong ?
I am using this code in order to put bitmaps to the menu.
But i cant get it work ! The Setmenuitembitmaps function return
0 which means it did fail !
My icon is of 13X13 pixels size and i tried it with a smaller
8X8 pixels size as well but it did not work !
Any help would be appreciated !
' in a module
Public Sub SetMenuBitmap(ByVal Picture As StdPicture, ByVal CheckedPicture As StdPicture, _
ByVal hWnd As Long, ParamArray menuPos() As Variant)
Dim hMenu As Long
Dim id As Long
Dim i As Long
Dim chkPicture As StdPicture
Dim kokoko, kokoko2 As Long
' provide a value for the CheckedPicture
If CheckedPicture Is Nothing Then
Set chkPicture = Picture
Else
Set chkPicture = CheckedPicture
End If
' get the handle of the toplevel menu
hMenu = GetMenu(hWnd)
' all the values in menuPos() except the last one
' are indexes of submenus
For i = 0 To UBound(menuPos) - 1
hMenu = GetSubMenu(hMenu, menuPos(i))
Next
' the last element in the paramarray is the
' index of a menu item
If Picture Is Nothing Then
SetMenuItemBitmaps hMenu, menuPos(UBound(menuPos)), MF_BYPOSITION, 0, 0
Else
SetMenuItemBitmaps(hMenu, menuPos(UBound(menuPos)), MF_BYPOSITION, Picture.handle, chkPicture.handle)
End If
End Sub
Public Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, _
ByVal nPos As Long) As Long
Public Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, _
ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As _
Long, ByVal hBitmapChecked As Long) As Long
Public Const MF_BYPOSITION = &H400&
private sub form_load()
Dim pic1 As StdPicture
Dim pic2 As StdPicture
Set pic1 = LoadPicture("c:start4.ico")
Set pic2 = LoadPicture("c:start4.ico")
Call SetMenuBitmap(pic1, pic2, Me.hWnd, 0, 0)
Call SetMenuBitmap(pic1, pic2, Me.hWnd, 0, 1)
Call SetMenuBitmap(pic1, pic2, Me.hWnd, 0, 2)
Call SetMenuBitmap(pic1, pic2, Me.hWnd, 1, 0)
end sub
Show Method (Should Be Easy???)
I have an MDIForm.
I also have several Standard Forms used to gather user info
which are called from the MDIForm menu.
Standard Forms display correctly, but take a bite out of my
MDI ToolBar bitmap when hidden.
Standard form would display in MDI Client area BUT:
when form is shown (tried it both modal and modeless)
it shows up centered on the screen.
Changing the standard forms Top property does not move form.
Any ideas how I can:
1. Refresh the underlying MDIForm when the standard form is
hidden,
OR
2. Somehow position the standard form other than screen centered.
Adding A Method
Is there any way to add a method to a collection aside from Add, Count, Item and Remove?
I've playing around with classes for hours now and I can't figure out a way to do so. Is is possible?
Adding Method
hi
how i can add methods in activex?
what i need?
thanks
OLE Bitmaps Ver. Long Binary Bitmaps
Hi,
I need to make a report that displays pictures stored in a data source. However, it seems that Crystal Report easily displays the picture if it was saved as OLE Bitmap. But mine was "Long Binary". Nothing is displayed in Crystal Report. How can I resolve this problem?
Adding "subsubmenu" Bitmaps...
Hello everyone...
I'm using the code below to add bitmaps to my menus...
Code:Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Const MF_BITMAP = &H4&
Private Sub AddIconToMenus_Click()
Dim i1 As Long, i2 As Long, Ret As Long
Dim MnHndl As Long
Dim SMnHndl As Long
Dim MCnt As Long
Dim SMCnt As Long
Dim SMnID As Long
MnHndl = GetMenu(Form1.hwnd) ' Get the menu handle for the current form
MCnt = GetMenuItemCount(MnHndl) ' Find out how many menus there are
For i1 = 0 To MCnt - 1 ' Process each menu entry
SMnHndl = GetSubMenu(MnHndl, i1) ' Get the next submenu handle for this menu
SMCnt = GetMenuItemCount(SMnHndl) ' Find out how many entries are in this submenu
For i2 = 0 To SMCnt - 1 ' Process each submenu entry
SMnID = GetMenuItemID(SMnHndl, i2) ' Get each entry ID for the current submenu
' Add two pictures - one for checked and one for unchecked
Ret = SetMenuItemBitmaps(MnHndl, SMnID, MF_BITMAP, Picture2.Picture, Picture1.Picture)
Next i2
Next i1
End Sub
Is there a function for adding bitmaps to a "subsubmenu"? Or can
someone modify the code above, if possible, to add bitmaps to
"subsubmenus"....
Much appreciated...
D-Race
Edited by - D-Race on 2/6/2005 12:33:36 AM
Adding To A Link Using The BeforeNavigate2 Method
Ok, so I built an application for an online game I play and it has an intergrated chat client in it using an OCX. unfortunitly I may have to take the chat client out becasue if the intergrated and ingame chat clients are both in use the OCX's start to cause problems with eachother. one workaround thought of was to add ?Browser=FEA to the end of every URL passed through the browser control as this would allow the game server to disable the ingame chat client. For some reason I have been unsuccessful in doing this, I have tried to add the below to the BeforeNavigate2 method.
VB Code:
If InStr(URL, "?") ThenIf InStr(URL, "?Browser=FEA") ThenElseURL = URL & "&Browser=FEA"End IfElseIf InStr(URL, "&Browser=FEA") ThenElseURL = URL & "?Browser=FEA"End IfEnd If
but this new parameter does not seem to be passed. Please give me some help here I don't want to have to remove the client but I'm out of idea's
- Ian L
Easy VB Adding?
Well, when i try to add 5 different numbenrs in the 5 different text boxes, it doesnt *** properly....
'If intTestPercentage + intQuizPercentage + intAssPercentage + intHWPercentage + intExamPercentage > 100 Then
'MsgBox "you have put more then 100%"
'ElseIf intTestPercentage + intQuizPercentage + intAssPercentage + intHWPercentage + intExamPercentage < 100 Then
'MsgBox "you have put less then 100%"
'ElseIf intTestPercentage + intQuizPercentage + intAssPercentage + intHWPercentage + intExamPercentage = 100 Then
'frmMarkScheme.Hide
'frmEditClass1.Show
As you can see, the 5 numbers have to equal 100, but they never do when they do actually add up to 100. It always says "you have put more then 100%" even when its equal to or less then 100. But when 1 textbox has the numbers, it works perfectly, telling me if i put over 100% or less than 100% or it exits successfully...
Im new to VB so show me some love
Easy , Adding Strings..
Hi.. may I know how to add two string in VB..
in C++, I do
Code:
CString str1,str2, str;
str1 = "c:\myfolder" ;
str2 = "pagecount.txt";
str = str1+ "\" + str2;
ofstring file;
file.open(str);
in VB I wrote,
Code:
Dim fileName As String
fileName = frmPrinterProperties.IDpath.Text & "pagecount.txt"
IDprefix.Text = fileName
Open fileName For Output As iFileNum ' opening file.. pagecount.txt
but only "pagecount.txt" shows and I can't open the file.. how to fix that?
thank you
Adding A Counter To An Easy Program
Hello everyone, Diesel here. I have one more question that I hope someone can help. The program that I have created, tells you in a messagebox if the letter r or n is the a word when you type it in an inputbox. But, my problem is that I have to make it count the amount of r's and n's in the word. The program is really easy, but it's a problem I just can't get around.
Here's the code...
Dim word As String, num1 As Integer, num2 As Integer
Private Sub cmdexit_Click()
End
End Sub
Private Sub CmdStart_Click()
num1 = 0
num2 = 0
Call jinput(word, num1, num2)
Call jprocess(word, num1, num2)
Call joutput(word, num1, num2)
End Sub
Private Sub jinput(word As String, num1 As Integer, num2 As Integer)
word = UCase(InputBox("Enter a word"))
End Sub
Private Sub jprocess(word As String, num1 As Integer, num2 As Integer)
num1 = InStr(word, "N")
num2 = InStr(word, "R")
End Sub
Private Sub joutput(word As String, num1 As Integer, num2 As Integer)
If num1 > 0 Then
MsgBox "This word contains the letter N"
Else
MsgBox "Sorry no N, try again"
End If
If num2 > 0 Then
MsgBox "This word contains the letter R"
Else
MsgBox "Sorry no R, try again"
End If
If num1 = 0 Then
num1 = 1000
End If
If num2 = 0 Then
num2 = 1000
End If
If num1 > num2 Then
MsgBox "The letter R comes first"
End If
If num2 > num1 Then
MsgBox "The letter N comes first"
End If
End Sub
Thanx
diesel
Easy Solution For Adding And Subtracting Time
I have two combo boxes. In each combo box the user can select a time. It basically is for a user to select what time he wants to run a certain train pattern. So lets say in the one combo box, he selects 8:00 and in the next he selects 12:00. What i need to do is find the difference and display how many hours the pattern is run. In this case it is 4 hours if it is 8:00 AM to 12:00PM and 16 hours if it is 8:00 AM to 12:00 AM. You see the mess you can get into. But, does vb have some time format that would make this easy to do, that would automatically do time subtraction and addition. Any suggestions would be greatly appreciated.
Thanks,
Jeff
How Do I Get To The VBF IRC Channel?
Ok. ive never used IRC.. im using the IRC client that comes built into Trillian, can anybody tell me how i would get into the Visual Basic Forum's IRC channel? Thanks
Trev
What Is A Channel?
Hi,
Just a quick question, what is a file for a channel or handle?
Thanks for your time,
Best wishes
Xenia Jones
What Is A Channel?
Hi,
Just a quick question, what is a file for a channel or handle?
Thanks for your time,
Best wishes
Xenia Jones
4 Channel Recording
Hi!
Does anyone know if it is possible to use sound card for recording with microphones inside the visual basic ?
Is it possible to use VB for four channel recording ?
Should I have a four channel sound card or is it possible to use two sound cards separately ?
What VB version should I have and what I should note when starting to make the basic program ?
Best thanks,
VBlab1
Opening An IRC Channel
is there VB 6.0 code similar to this VB 2005 express code:
VB Code:
Process.Start("iexplore", URL)
The URL is actually a URL for an IRC channel, so that code opened up mIRC directly and instantly to the correct server and channel.
With VB 6.0 I've been using this code:
VB Code:
Set s = CreateObject("InternetExplorer.application") s.Visible = True s.Navigate URL
This takes a lot longer than the VB 2005 code because it opens up my default browser first and then opens mIRC. Is there a way to get the instantanious opening to mIRC that I got with VB 2005 with VB 6.0?
Talking In Irc In A Channel Thru My App
i've made an app that connects to an irc server and then joins a channel and everything comes ok but how do i talk in private to someone or in the channel? ive tried for private message to put: /QUERY <NICK> <MSG> and it says that he doesnt understand the command...*** am i doing wrong?!
Left && Right Channel
Doe's anyone know how i can play one wav file to the left speaker channel and another one through the right speaker channel of the sound card at the same time.
Or is there an API that i can use to control the balance?
Thanks to all in advance
What Is A Channel In A Sound.
I want to know what exactly is "channel" in a sound ? Is it left and right sound outputs to the speaker.
I want to play a mp3 using some code. It asks how much channels it must use. What is the default value for a sound card ?
IRC Join Channel Problem
I haven't done very extensive programming with IRC but i've gotten through connecting and all that stuff, and i've got a basic communication going with an irc server, however heh..... whenever i attempt to join a channel my program crashes, everytime. I was just wondering if anyone knew why this would happen,
all my program does basically is receve a string from the server and add it to a text box. I was thinking it might have something to do with the characters that are being sent and then moved into there, I'm not sure.if anyone has some tips or advice i would appretate it alot thanks.
Mp3 Player With 6 Channel Sound
i want to play 6 different mp3 file at same time using 5.1 soundcard...:
file 1 play in speaker front left
file 2 play in speaker front right
file 3 play in speaker center
etc..
i have tried with direct sound..with wav file..and it work
but now i want try with mp3 file.
anyone have idea what must i do or anyone have simple code about this?
thx
Sound Channel Problem
I'm trying to find a solution to my sound channel mapping problem. I need to play the sound from one channel on both speakers. For example, play left channel audio on both left and right audio channels.
I have been looking for a solution to this but so far no good.
Please help, thank you.
Chance Input Channel?
Is it possible to set the input channel of my capture card dynamically at run time, without the user having to manually do it?
I hope somebody can help me..
bye
Reader && Communication Channel
I have problem when i try to read the data from my smart card into my program. Run-time Error occur!
ChannelNb = G4_OpenChannel(Channel)
The value that i get for the ChannelNb is -520
It is suppose to be either 1 or 0
I dun know what's wrong with my program?
I try to run my program at other PC, it is no problem at all.
I try to read data from the card using the Reader Vendor program. it is also dun have any problem at all.
IRC Channel Listing On Server
Ok guys, i need help. I am developing my own irc bot in VB 6, but i have problem , i dont know how to list channels on the server, like /list command in mIRC.
I want to list channels and to put them in ListBox.
Please help me if u can. I am desperate.
Sound Channel Problem.
I'm trying to find a solution to my audio channel mapping problem. I need to play sound from one channel to both speakers. For example, play left channel sound on both left and right channels. Please help.
|