Ver Mensaje Individual
  #6 (permalink)  
Antiguo 28/10/2010, 05:06
Avatar de pkj
pkj
 
Fecha de Ingreso: julio-2006
Ubicación: Órbita sincrónica
Mensajes: 899
Antigüedad: 17 años, 9 meses
Puntos: 29
Respuesta: comparar el contenido de 2 image diferentes

No sé como lo haces, pero si arrastras los pictures como imagino, moviendo el contenido pero no cambiando de sitio el propio picture, podrías comparar las imágenes como cadenas de texto y contar las que coinciden:

Código vb:
Ver original
  1. Private Declare Function GetBitmapBits Lib "gdi32" _
  2.     (ByVal hBitmap As Long, ByVal dwCount As Long, _
  3.     lpBits As Any) As Long
  4.  
  5. Private Declare Function GetObject Lib "gdi32" Alias _
  6.     "GetObjectA" (ByVal hObject As Long, ByVal nCount _
  7.     As Long, lpObject As Any) As Long
  8.  
  9. Private Type BITMAP
  10.       bmType As Long
  11.       bmWidth As Long
  12.       bmHeight As Long
  13.       bmWidthBytes As Long
  14.       bmPlanes As Integer
  15.       bmBitsPixel As Integer
  16.       bmBits As Long
  17. End Type
  18.  
  19. Private Function PictureToString(pic As PictureBox) As String
  20.  
  21.       Dim tBitmap As BITMAP
  22.       Dim bPicBytes() As Byte
  23.       Dim lByteLen As Long
  24.       GetObject Picture1.Image.Handle, Len(tBitmap), tBitmap
  25.       lByteLen = tBitmap.bmWidthBytes * tBitmap.bmHeight
  26.       ReDim bPicBytes(1 To lByteLen)
  27.       GetBitmapBits pic.Picture.Handle, UBound(bPicBytes), bPicBytes(1)
  28.        
  29.       PictureToString = bPicBytes
  30. End Function
  31.  
  32. Private Function ComparaPics(Pic1 As PictureBox, Pic2 As PictureBox) As Boolean
  33.   Dim strPic1 As String
  34.   Dim strPic2 As String
  35.  
  36.   strPic1 = PictureToString(Pic1)
  37.   strPic2 = PictureToString(Pic2)
  38.  
  39.   ComparaPics = (strPic1 = strPic2)
  40.  
  41. End Function

Y cuando desplaces un picture comparas todos.

Dim Iguales As Integer
If ComparaPics(Form1.Picture1, Form2.Picture1) Then iguales = iguales + 1
If ComparaPics(Form1.Picture2, Form2.Picture2) Then iguales = iguales + 1
If ComparaPics(Form1.Picture3, Form2.Picture3) Then iguales = iguales + 1
If iguales=3 Then Msgbox "Completado"

Saludos
__________________
No hay preguntas tontas, solo gente estup..., ¡No!, ¿como era? No hay gente que pregunte a tontos... ¡Nooo!... ¡Vaya cabeza!