fast grayscaling a big bitmap trucolor (like 12000y, 9600x pix) in vb6
I already googled a lot, take GDI+ tutorials, and everything. But I
don't want it in the slow way
So, I wondered if that well know VB code about making a colourmatrix
is possible to translate to work in VB5/6?
[CODE]
Dim dlg As OpenFileDialog = New OpenFileDialog()
dlg.Filter = "Image files (*.BMP, *.JPG, *.GIF)|*.bmp;*.jpg;*.gif"
If dlg.ShowDialog() = DialogResult.OK Then
Dim img As Image = Image.FromFile(dlg.FileName)
Dim bm As Bitmap = New Bitmap(img.Width, img.Height)
Dim g As Graphics = Graphics.FromImage(bm)
Dim cm As ColorMatrix = New ColorMatrix(New Single()() _
{New Single() {0.3, 0.3, 0.3, 0, 0}, _
New Single() {0.59, 0.59, 0.59, 0, 0}, _
New Single() {0.11, 0.11, 0.11, 0, 0}, _
New Single() {0, 0, 0, 1, 0}, _
New Single() {0, 0, 0, 0, 1}})
Dim ia As ImageAttributes = New ImageAttributes()
ia.SetColorMatrix(cm)
g.DrawImage(img, New Rectangle(0, 0, img.Width, img.Height), 0,
0, img.Width, img.Height, GraphicsUnit.Pixel, ia)
g.Dispose()
Me.BackgroundImage = bm
End If
[/CODE]
strip out the img loading lines, i already have the image in a
StdPicture, maybe I can to setup a DC and selecting the bitmap of the
stdpicture but... how to implement that colorMatrix thing in VB6?
anybody has the routine already done? i don't want to reinvent the
whell.
Leer las respuestas