Vuen
Sep 13th, 2000, 06:13 PM
Everyone is always saying how FAST set/getpixelling on a memDC is fast and its SLOW LIKE HELL FOR ME! SO WHAT AM I DOING WRONG! Okay. This code WORKS PERFECTLY, except for the fact that its SLOW. This is how my prog makes a DC, and changes some of the colors in it. I think the problem is that it's how I create the memDC, but well here you go.
I've declared all the APIs I'll be using so im not gonna show them, and picGame is a blank picture box, and the Imagelist contains a 50x50 sprite that is being drawn:
UnitSprites(i) = CreateCompatibleDC(frmGame.picGame.hdc)
UnitSpritesBitmaps(i) = CreateCompatibleBitmap(frmGame.picGame.hdc, 50, 50)
SelectObject UnitSprites(i), UnitSpritesBitmaps(i)
frmGame.UnitList(5).ListImages(i).Draw UnitSprites(i), 0, 0, 0
For i2 = 0 To 49
For i3 = 0 To 49
pixel = GetPixel(UnitSprites(i), i2, i3)
If pixel <> RGB(255, 255, 0) Then
For i4 = 0 To 15
If pixel = RGB(90 + i4 * 11, 0, 90 + i4 * 11) Then SetPixelV UnitSprites(i), i2, i3, RGB(Color(1, 1) * (i4 / 16), Color(1, 2) * (i4 / 16), Color(1, 3) * (i4 / 16))
If pixel = RGB(0, 0, 90 + i4 * 11) Then SetPixelV UnitSprites(i), i2, i3, RGB(Color(2, 1) * (i4 / 16), Color(2, 2) * (i4 / 16), Color(2, 3) * (i4 / 16))
If pixel = RGB(0, 90 + i4 * 11, 0) Then SetPixelV UnitSprites(i), i2, i3, RGB(Color(3, 1) * (i4 / 16), Color(3, 2) * (i4 / 16), Color(3, 3) * (i4 / 16))
Next i4
End If
Next i3
Next i2
[Edited by Vuen on 09-13-2000 at 07:24 PM]
I've declared all the APIs I'll be using so im not gonna show them, and picGame is a blank picture box, and the Imagelist contains a 50x50 sprite that is being drawn:
UnitSprites(i) = CreateCompatibleDC(frmGame.picGame.hdc)
UnitSpritesBitmaps(i) = CreateCompatibleBitmap(frmGame.picGame.hdc, 50, 50)
SelectObject UnitSprites(i), UnitSpritesBitmaps(i)
frmGame.UnitList(5).ListImages(i).Draw UnitSprites(i), 0, 0, 0
For i2 = 0 To 49
For i3 = 0 To 49
pixel = GetPixel(UnitSprites(i), i2, i3)
If pixel <> RGB(255, 255, 0) Then
For i4 = 0 To 15
If pixel = RGB(90 + i4 * 11, 0, 90 + i4 * 11) Then SetPixelV UnitSprites(i), i2, i3, RGB(Color(1, 1) * (i4 / 16), Color(1, 2) * (i4 / 16), Color(1, 3) * (i4 / 16))
If pixel = RGB(0, 0, 90 + i4 * 11) Then SetPixelV UnitSprites(i), i2, i3, RGB(Color(2, 1) * (i4 / 16), Color(2, 2) * (i4 / 16), Color(2, 3) * (i4 / 16))
If pixel = RGB(0, 90 + i4 * 11, 0) Then SetPixelV UnitSprites(i), i2, i3, RGB(Color(3, 1) * (i4 / 16), Color(3, 2) * (i4 / 16), Color(3, 3) * (i4 / 16))
Next i4
End If
Next i3
Next i2
[Edited by Vuen on 09-13-2000 at 07:24 PM]