|
-
Feb 7th, 2000, 06:39 AM
#1
Thread Starter
So Unbanned
I need to get the RGB value or Hex color value of all the pixels in a picturebox.
Thanks,
------------------
DiGiTaIErRoR
VB, QBasic, Iptscrae, HTML
Quote: There are no stupid questions, just stupid people.
-
Feb 7th, 2000, 06:46 AM
#2
Try the Point() Method, ie.
Code:
Private Sub Form_Load()
Picture1.MousePointer = vbCrosshair
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Caption = Hex$(Picture1.Point(X, Y))
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Certified AllExperts Expert
-
Feb 7th, 2000, 07:37 AM
#3
Addicted Member
This is another (a little more complicated) way:
Public Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO_24, ByVal wUsage As Long) As Long
Public Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Public Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Public Type BITMAPFILEHEADER
bfType As Integer
bfSize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfOffBits As Long
End Type
Public Type BITMAPINFO_24
bmiHeader As BITMAPINFOHEADER
End Type
Public Const DIB_RGB_COLORS = 0
Public Const CCHDEVICENAME = 32
Public Const CCHFORMNAME = 32
Public Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Long
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Public pixelbuf() As RGBQUAD
Public bufsize&
Public BInfo As BITMAPINFO_24
Public Max
Function DIBits(dx, dy, Pdc As Long, PHandle As Long) As Long
On Error Resume Next
With BInfo.bmiHeader
.biSize = 40
.biWidth = Screen.Width / Screen.TwipsPerPixelX
.biHeight = Screen.Height / Screen.TwipsPerPixelY
.biPlanes = 1
.biBitCount = 32
.biCompression = 0
.biClrUsed = 0
.biClrImportant = 0
.biSizeImage = bufsize
End With
bufsize = dx * dy
ReDim pixelbuf(0 To bufsize - 1)
retv = GetDIBits(Pdc, PHandle, 0, BInfo.bmiHeader.biHeight, pixelbuf(0), BInfo, DIB_RGB_COLORS)
Max = (dx) * (dy) - 1
DIBits = retv
End Function
The pixelbuf array now contains every pixel's RGB Values
------------------
Razzle
ICQ#: 31429438
What is the difference between a raven?
-The legs. The length is equal, especially the right one.
-
Feb 7th, 2000, 07:49 AM
#4
Thread Starter
So Unbanned
I need to do it automattically and not under the mouse or whatever. I need the hex value though and not the RGB value.
Thanks,
------------------
DiGiTaIErRoR
VB, QBasic, Iptscrae, HTML
Quote: There are no stupid questions, just stupid people.
-
Feb 7th, 2000, 08:13 AM
#5
Thread Starter
So Unbanned
Ok, well I got all the hex color values now how would I go about repainting the hex values in another picturebox? I'm trying to create a program to store it's images itself so I don't have to use 1 meg BMP's anyone?
Thanks,
------------------
DiGiTaIErRoR
VB, QBasic, Iptscrae, HTML
Quote: There are no stupid questions, just stupid people.
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
|