Toon posts:

[vb] Hoe kan dit sneller?

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ik doe het nu zo

for y =0 to 200
for x= 0 to 200
array(x,y)= getpixel(picture.hdc,x,y)
next x
next y

^^^^^dit gaat traaaag |:(

Bestaat er ook een functie om gelijk de hele inhoud van een hdc in een array te gooien?

alvast bedankt. :)

  • Gerco
  • Registratie: Mei 2000
  • Laatst online: 14-09 17:42

Gerco

Professional Newbie

Niet dat ik weet, maar wat wil je ermee doen? Misschien is daar wel een snelle manier voor.

edit:

Dit is misschien ook wel handig, maar ik heb verder niet nagekeken of dit ook bruikbaar is, laat staan vanuit VB :9

The GetDIBits function retrieves the bits of the specified bitmap and copies them into a buffer using the specified format.
[code]int GetDIBits(
HDC hdc, // handle to device context
HBITMAP hbmp, // handle to bitmap
UINT uStartScan, // first scan line to set in destination bitmap
UINT cScanLines, // number of scan lines to copy
LPVOID lpvBits, // address of array for bitmap bits
LPBITMAPINFO lpbi, // address of structure with bitmap data
UINT uUsage // RGB or palette index
);[/code]

- "Als ik zou willen dat je het begreep, legde ik het wel beter uit!" | All number systems are base 10!


Verwijderd

Topicstarter
Op maandag 22 oktober 2001 19:36 schreef Gerco het volgende:
Niet dat ik weet, maar wat wil je ermee doen? Misschien is daar wel een snelle manier voor.

edit:

Dit is misschien ook wel handig, maar ik heb verder niet nagekeken of dit ook bruikbaar is, laat staan vanuit VB :9

The GetDIBits function retrieves the bits of the specified bitmap and copies them into a buffer using the specified format.
[code]int GetDIBits(
HDC hdc, // handle to device context
HBITMAP hbmp, // handle to bitmap
UINT uStartScan, // first scan line to set in destination bitmap
UINT cScanLines, // number of scan lines to copy
LPVOID lpvBits, // address of array for bitmap bits
LPBITMAPINFO lpbi, // address of structure with bitmap data
UINT uUsage // RGB or palette index
);[/code]
Bedankt,
Ik zal er naar kijken, als het werkt post ik de source hier.

Verwijderd

Deze heb ik nog ergens liggen, misschien heb je er iets aan.
Tis niet op een hDC, maar op een .Picture:
code:
1
2
3
4
5
6
7
Private Declare Function GetBitmapBits Lib "gdi32" _
  (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long

Dim bmByte() As Long

    ReDim bmByte(0 To Width - 1, 0 To Height - 1)
    Call GetBitmapBits(pict.Picture, (Width * Height) * 4, bmByte(0, 0))

En dan natuurlijk voor alle items in de array:
code:
1
2
3
4
    Let c = bmByte(x, y) 
    Let R = c And 255
    Let G = (c And 65280) \ 256
    Let B = (c And 16711680) \ 65536

[edit]
Overigens heb je gelijk dat je dit met een array moet doen. Snelheid is echt een verschil tussen dag en nacht.