[VB6] - About GetDIBits()
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?
Re: [VB6] - About GetDIBits()
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
Quote:
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().
Re: [VB6] - About GetDIBits()
Quote:
Originally Posted by
Mikle
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().
thanks;)
Code:
inWidth = Picture.ScaleWidth
inHeight = Picture.ScaleHeight
ReDim OriginalImage(inWidth - 1, inHeight - 1)
With bi32BitInfo.bmiHeader
.biBitCount = 32
.biPlanes = 1
.biSize = Len(bi32BitInfo.bmiHeader)
.biWidth = inWidth
.biHeight = inHeight
.biSizeImage = 4 * inWidth * inHeight
End With
GetDIBits Picture.hdc, Picture.Image.Handle, 0, inHeight, OriginalImage(0, 0), bi32BitInfo, 0
like you see the size is, always positive. but someone tell me that DIB's works upside down. maybe is why my code is ignored or inverted on Y:(
Re: [VB6] - About GetDIBits()
but if the Y is inverted, how can i work with it?
Re: [VB6] - About GetDIBits()
I wrote:
Quote:
Y coordinate is from bottom to top, to change it from top to bottom, you need to BITMAPINFOHEADER.biHeight write a negative number
Change
Code:
.biHeight = inHeight
to
Code:
.biHeight = -inHeight
Re: [VB6] - About GetDIBits()
Quote:
Originally Posted by
Mikle
I wrote:
Change
Code:
.biHeight = inHeight
to
Code:
.biHeight = -inHeight
if i change that, i must change the way the image is drawed, right?
Re: [VB6] - About GetDIBits()
You need change it for GetDiBits and for SetDiBitsToDevice simultaneously. Then you no longer need to change.
Re: [VB6] - About GetDIBits()
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?
Re: [VB6] - About GetDIBits()
SetDiBitsToDevice () is for draw it. but don't help me on Transparent and stretch draw:(
Re: [VB6] - About GetDIBits()
Give me you working code where you have problem.
1 Attachment(s)
Re: [VB6] - About GetDIBits()
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.
Re: [VB6] - About GetDIBits()
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?
Re: [VB6] - About GetDIBits()
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
And for the cycle on X similarly.
1 Attachment(s)
Re: [VB6] - About GetDIBits()
sorry, but the results are a black image(black color with image size):(
see the class. if you want, give me your mail and i send you the entire project
Re: [VB6] - About GetDIBits()
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?
Re: [VB6] - About GetDIBits()
now i understand why the shadow effects wasn't workin with some values: because without any data\pixel we can't compare values lol