|
-
Apr 16th, 2003, 06:12 PM
#1
-
Apr 17th, 2003, 08:37 AM
#2
Lively Member
Sorry I don't fully understand your question...
Do you mean that you want to use a bitmap texture as a brush?
if so look here or here
unfortunately the examples are not in VB but the GDI+ API's are largely the same across .NET languages.
-
Apr 17th, 2003, 02:02 PM
#3
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Apr 18th, 2003, 12:38 AM
#4
Frenzied Member
I guess you are writing 'Mr.Polite Photoshop' to replace 'Adobe Photoshop' . Great! We back you all. Good Luck
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Aug 5th, 2003, 03:01 PM
#5
Originally posted by Lunatic3
I guess you are writing 'Mr.Polite Photoshop' to replace 'Adobe Photoshop' . Great! We back you all. Good Luck
ok I started working on this crappy program of mine again... I thought a little about this texture thing and I figured it out.
here's what I do: I convert the texture to grayscale. The whitemost pixels (highest r, g, or b value) will have the most transparency. The darkmost pixels will be the least transparent pixels when you are applying the texture:
VB Code:
' Modifies the ORIGINAL bitmap and also returns a reference to it
Public Shared Function ApplyTexture(ByRef bmp As Bitmap, ByVal textureTransparency As Single) As Bitmap
If bmp Is Nothing Then Throw New ArgumentNullException
If textureTransparency < 0 OrElse textureTransparency > 1 Then
Throw New ArgumentOutOfRangeException("textureTransparency must be between 0 and 1.")
End If
bmp = MakeImageGrayscale(bmp)
Dim x, y As Integer
Dim alpha As Integer
For x = 0 To bmp.Width - 1
For y = 0 To bmp.Height - 1
Dim c As Color = bmp.GetPixel(x, y)
' c.R -> all of the RGB values are the same since the image is grayscale.
alpha = CInt(c.R * textureTransparency)
c = Color.FromArgb(alpha, c)
bmp.SetPixel(x, y, c)
Next
Next
Return bmp
End Function
Public Shared Function MakeImageGrayscale(ByVal bmp As Bitmap) As Bitmap
Dim imageAttrib As ImageAttributes = GetGrayscaleAttr()
Return ApplyImageAttribute(bmp, imageAttrib)
End Function
Public Shared Function GetGrayscaleAttr() As ImageAttributes
Dim values()() As Single = {New Single() {0.5, 0.5, 0.5, 0, 0}, _
New Single() {0.5, 0.5, 0.5, 0, 0}, _
New Single() {0.5, 0.5, 0.5, 0, 0}, _
New Single() {0, 0, 0, 1, 0}, _
New Single() {0, 0, 0, 0, 1}}
' Use the matrix to initialize a new colorMatrix object
Dim colMatrix As New ColorMatrix(values)
Dim imageAttr As New ImageAttributes
imageAttr.SetColorMatrix(colMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap)
Return imageAttr
End Function
Public Shared Function ApplyImageAttribute(ByVal img As Bitmap, ByVal imageAttrib As ImageAttributes) As Bitmap
Dim bmp As New Bitmap(img.Width, img.Height)
Dim gr As Graphics = Graphics.FromImage(bmp)
gr.DrawImage(img, New Rectangle(0, 0, img.Width, img.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imageAttrib)
Return bmp
End Function
I just copy pasted my code from my project... you can combine all those a3 functions for converting to grayscale if you want
edit: ahem, would it be more efficient if I converted the image to grayscale myself in that first forloop? or would applying an image attribute be faster?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|