|
-
Jun 25th, 2001, 04:30 PM
#1
Thread Starter
Junior Member
Bitmap in memory
How do I get a Bitmap in the memory and if it is in the memory, how can I edit the bitmap pixel per pixel??
Thanks...
-
Jun 25th, 2001, 07:13 PM
#2
Good Ol' Platypus
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Jun 25th, 2001, 08:55 PM
#3
You can a Bitmap into memory very simply, by using the VB LoadPicture() function.
You could just load the image directly into a Picturebox (which is technically in memory) or if you want to create a Memory DC yourself and store it there do something like this:
VB Code:
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Private Sub Command1_Click()
Dim lDC As Long
Dim lBMP As IPictureDisp
Picture1.ScaleMode = vbPixels
' Create a Memory Device Context to hold the Image you want to manipulate
lDC = CreateCompatibleDC(0)
' Load the Image
Set lBMP = LoadPicture("C:\Windows\Clouds.bmp")
' Select it into the new DC
Call SelectObject(lDC, lBMP)
' Manipulate the image via the Device Context (lDC)
' Then BitBlt it to a Picturebox or other device context
Call BitBlt(Picture1.hdc, 0, 0, ScaleX(lBMP.Width, vbHimetric, vbPixels), ScaleY(lBMP.Height, vbHimetric, vbPixels), lDC, 0, 0, SRCCOPY)
' always clean up DC's or Objects you create in order to restore GDI resources.
Call DeleteDC(lDC)
Set lBMP = Nothing
End Sub
There are several GDI API's you can use for altering the image, such as GetPixel and SetPixel
-
Jun 26th, 2001, 12:29 AM
#4
transcendental analytic
Unlimited realities has some DMA samples; provides fast access with a pointer to a byte array
http://www.ur.co.nz/
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|