i know that GetDIBits() converts RGB to BGR colors(it's how they work).
but for work with coordinates theres any diference??
or do i need convert them for compare them(using '+' or '-')?
i always do:
Code:
For Y = 0 To Height - 1
For X = 0 To Width - 1
'..........
next X
next y
but i can use pixel(x+2, y+3) for compare the colors(converted to BGR) or i must convert the coordenates too?
Function GetDIBits() and SetDIBitsToDevice() work with the parameter BITMAPINFOHEADER, Y coordinate is from bottom to top, to change it from top to bottom, you need to BITMAPINFOHEADER.biHeight write a negative number, for example:
Code:
With bi32BitInfo.bmiHeader
.biBitCount = 32
.biPlanes = 1
.biSize = Len(bi32BitInfo.bmiHeader)
.biWidth = pic.ScaleWidth
.biHeight = -pic.ScaleHeight
.biSizeImage = 4 * pic.ScaleWidth * pic.ScaleHeight
End With
To convert RGB to BGR, the coordinates do not need to change, that the transformation function RGB to BGR and BGR to RGB the same way:
Code:
Private Function SwapRGB(ByVal c As Long) As Long
SwapRGB = (c And &HFF&) * &H10000 Or (c And &HFF00&) Or (c And &HFF0000) \ &H10000
End Function
i know that GetDIBits() converts RGB to BGR colors(it's how they work).
It is not, on the contrary, in VB6 color components are mixed for compatibility with older versions of BASIC, I recommend not to use functions RGB(), PSet(), Point() and constants, such vbRed, vbBlack ..., instead PSet() and Point() to use the SetPixel() and GetPixel().
Function GetDIBits() and SetDIBitsToDevice() work with the parameter BITMAPINFOHEADER, Y coordinate is from bottom to top, to change it from top to bottom, you need to BITMAPINFOHEADER.biHeight write a negative number, for example:
Code:
With bi32BitInfo.bmiHeader
.biBitCount = 32
.biPlanes = 1
.biSize = Len(bi32BitInfo.bmiHeader)
.biWidth = pic.ScaleWidth
.biHeight = -pic.ScaleHeight
.biSizeImage = 4 * pic.ScaleWidth * pic.ScaleHeight
End With
To convert RGB to BGR, the coordinates do not need to change, that the transformation function RGB to BGR and BGR to RGB the same way:
Code:
Private Function SwapRGB(ByVal c As Long) As Long
SwapRGB = (c And &HFF&) * &H10000 Or (c And &HFF00&) Or (c And &HFF0000) \ &H10000
End Function
It is not, on the contrary, in VB6 color components are mixed for compatibility with older versions of BASIC, I recommend not to use functions RGB(), PSet(), Point() and constants, such vbRed, vbBlack ..., instead PSet() and Point() to use the SetPixel() and GetPixel().
ok... i know that i must change the StretchDIBits() for draw the image.
but i still having problems with Y
because TempY = Y + lngShadowY
and if lngShadowY >=0 the shadow is ignored
if i use it positive, the problem is inversed and the lngShadowY accept >=0 values correctly
and i don't understand why
can you advice me?
sorry the late. didn't see it
heres how you use the class:
Code:
Dim GRP As Graphics
Private Sub Command1_Click()
Set GRP = New Graphics
Form1.Cls
GRP.GetImageData Picture1 'get the image from a control
GRP.ShadowColor = Picture6.BackColor
GRP.ShadowX = Val(Text2.Text)
GRP.ShadowY = Val(Text3.Text)
GRP.DrawImage Form1 'draw the image on control
End Sub
on class you have the getimagedata() sub, changeimage() sub(here we do all effects). on changeimage() sub see the comments for catch the shadow effect.
the drawimage() sub is for draw the image and see how i do the mirror and tiles\stretch.
after some tests i found these:
with: TempY = Y - lngShadowY
if ShadowY=0 then the ShadowX must be negative(don't make sence using the 0, in these sample);
if ShadowY>0 then ShadowX can be any number;
if ShadowY<0 then the shadow isn't showed. the values are ignored
can anyone advice me?
You're in the loop will be overwritten by the new color previously drawn shadow. Replace in the Sub ChangeImage() the line:
Code:
For Y = 0 To outHeight - 1
to fragment:
Code:
Dim y_for As Long, y_to As Long, y_step As Long
If lngShadowY > 0 Then
y_for = outHeight - 1
y_to = 0
y_step = -1
Else
y_for = 0
y_to = outHeight - 1
y_step = 1
End If
For Y = y_for To y_to Step y_step
hehehe i put the shadow working hehehe
what i did?
well i create a second array for put the shadow image and other for it's mask(for do the transparency) and works fine. and for draw it i can choose the place, because, here, i don't use the Y coordenate
now i must complete my selection effect(is show 1 line arrow the image(image without backcolor).. like in games):
Code:
'Selection Color(needs more work)
If lngSelectionWidth <> 0 And lngSelectionColor <> lngBackColor Then
clrOldColor = RGBValues(lngBackColor)
TempColor = RGB(clrOldColor.Blue, clrOldColor.Green, clrOldColor.Red)
clrOldColor = RGBValues(lngSelectionColor)
TempColor1 = RGB(clrOldColor.Blue, clrOldColor.Green, clrOldColor.Red)
If (ChangedImage(X, Y) = TempColor And blnLeft = True) Then
For i = 1 To SelectionWidth
ChangedImage(X - i, Y) = TempColor1
MaskImage(X - i, Y) = vbBlack
Next i
blnLeft = False
ElseIf (ChangedImage(X, Y) <> TempColor And blnLeft = False) Then
For i = 1 To SelectionWidth
ChangedImage(X - i, Y) = TempColor1
MaskImage(X - i, Y) = vbBlack
Next i
blnLeft = True
End If
End If
these code works fine for X(left-right), but i don't know how can i put it working for Y(up-down).
any advices?