|
-
Jan 4th, 2005, 10:46 PM
#1
Thread Starter
Addicted Member
Bitmaps & INIs: Newbie Qestions
I'm a total beginner in VB programming, and critically need two functions for a small program I'm writing. First would be how to resize or at least crop Bitmaps(as a file). And the second one, although not as crucial, is how would I go about modifying an existing INI file, or to be exact replacing a preset integer value with a constant(0).
Thanx in advance.
-
Jan 4th, 2005, 10:52 PM
#2
Re: Bitmaps & INIs: Newbie Qestions
Planet Source Code helps with your bitmap problem. Also, you can use LoadPicture and SavePicture to load and save pictures.
-
Jan 4th, 2005, 10:56 PM
#3
Thread Starter
Addicted Member
Re: Bitmaps & INIs: Newbie Qestions
Thanx a lot. What about the second question?
-
Jan 5th, 2005, 12:03 AM
#4
Addicted Member
Re: Bitmaps & INIs: Newbie Qestions
INI Manipulation is very easy with two simply API, or 3, depending on what type of data you are manipulating. You said you were using integers, so this should do fine
VB Code:
Private Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Sub Command1_Click()
Call WritePrivateProfileString("SECTION", "KEY", "45", "C:\test.ini")
MsgBox GetPrivateProfileInt("SECTION", "KEY", 0, "C:\test.ini")
'now view the ini file and see how it is structured in code.
'If you want to read a string from the ini file, you will have to use
'the GetPrivateProfileString api instead of GetPrivateProfileInt
End Sub
Artificial Intelligence At War! - The best game of its genre
Program your own robot and watch it fight in 3d!
Droidarena 3
If I have been useful, please Rate My Post
Support FireFox - 
Microsoft Visual Studio .NET Professional 2003
Microsoft Visual Studio 6, Enterprise Edition
Microsoft Windows XP Professional, Service Pack 2
-
Jan 5th, 2005, 04:00 AM
#5
Thread Starter
Addicted Member
Re: Bitmaps & INIs: Newbie Qestions
Mucho Gracias! Now, sorry if I'm going offtopic :blush:, but I've 2 more questions... Is it possible to detect a creation of file(created by another program) and trigger an event when it happens? Or detect a keystroke when the another (full-screen) program has the focus(it may be of significance that the other program detects it as well)?
Let me explain the concept of what I'm doing. It's a mod for a video game. Mainly, I want the player to be able to make photos ingame. This proggy I'm writing handles the detection of taking a screnshot(pressing the PrntScrn button), then copies the file that is created to another folder and resizes/crops it. Then the ingame scripting engine kicks in, makes a mesh, and applies the file copied by the program as a texture. The ingame scripting isn't of any difficulty to me, but it doesn't handle file-management like that, so I had to write that part externally, and since the only language I at least have a clue about is VB...
Oh, and I've found this bit of code on Planet Source Code for resizing bitmaps:
Code:
Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC%, ByVal X%, ByVal Y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal xSrc%, ByVal ySrc%, ByVal dwRop&) As Integer
But the author mentions that the color pallette has to be reduced to 256 if using this function, and unfortunately this is not acceptable in this case, plus I'm not exactly sure what they mean by some of the vars... So, would anyone be kind enough as to give another way to do this?
-
Jan 5th, 2005, 11:30 PM
#6
Thread Starter
Addicted Member
Re: Bitmaps & INIs: Newbie Qestions
Sorry to bump, but I really need it. The bitmap resizing part.
-
Jan 6th, 2005, 12:56 AM
#7
Re: Bitmaps & INIs: Newbie Qestions
can you use the picturebox resize property?
-
Jan 6th, 2005, 03:44 AM
#8
Thread Starter
Addicted Member
Re: Bitmaps & INIs: Newbie Qestions
What do you mean? There's a resize event for a PBox, but it just registers the resize of the control. What I need is open a Bitmap, resize it, and save with the new size, and there's no property for the PBox that does that AFAIK.
Oh, and what's wrong with this:
VB Code:
Call SavePicture(Picture2.Picture, "D:\max_tx_photo_2.bmp")
The picture exists, and the drive as well. But it gives me an "Invalid Property Value" error...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|