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...
Printable View
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...
See this thread for ideas.
http://161.58.186.97/showthread.php?s=&threadid=80662
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:There are several GDI API's you can use for altering the image, such as GetPixel and SetPixelVB 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
Unlimited realities has some DMA samples; provides fast access with a pointer to a byte array
http://www.ur.co.nz/