نمایش نتایج 1 تا 40 از 105

نام تاپیک: نکات، ایده ها و ترفندهای کوچک برنامه نویسی در vb.net

Hybrid View

پست قبلی پست قبلی   پست بعدی پست بعدی
  1. #1
    کاربر دائمی آواتار ghafoori
    تاریخ عضویت
    مرداد 1384
    محل زندگی
    اصفهان-نجف اباد
    پست
    1,111

    Smile تبدیل یک تصویر رنگی به معادل GrayScal آن

    https://barnamenevis.org/showpo...9&postcount=96

    Imports System.Drawing.Imaging


    Public Shared Function MakeGrayscale(ByVal original As Bitmap) As Bitmap

    ' //create a blank bitmap the same size as original
    Dim newBitmap As Bitmap = New Bitmap(original.Width, original.Height)

    '//get a graphics object from the new image
    Dim g As Graphics = Graphics.FromImage(newBitmap)

    '//create the grayscale ColorMatrix
    Dim array()() As Single = New Single()() {New Single() {0.3F, 0.3F, 0.3F, 0, 0}, _
    New Single() {0.59F, 0.59F, 0.59F, 0, 0}, _
    New Single() {0.11F, 0.11F, 0.11F, 0, 0}, _
    New Single() {0, 0, 0, 1, 0}, _
    New Single() {0, 0, 0, 0, 1}}
    Dim colorMatrix As ColorMatrix = New ColorMatrix(array)

    '//create some image attributes
    Dim attributes As ImageAttributes = New ImageAttributes()

    '//set the color matrix attribute
    attributes.SetColorMatrix(colorMatrix)

    '//draw the original image on the new image
    '//using the grayscale color matrix
    g.DrawImage(original, New Rectangle(0, 0, original.Width, _
    original.Height), 0, 0, original.Width, _
    original.Height, GraphicsUnit.Pixel, attributes)

    '//dispose the Graphics object
    g.Dispose()
    Return newBitmap
    End Function

    Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    Dim b As Bitmap = PictureBox1.Image

    PictureBox2.Image = MakeGrayscale(b)
    End Sub

  2. #2
    کاربر دائمی آواتار ghafoori
    تاریخ عضویت
    مرداد 1384
    محل زندگی
    اصفهان-نجف اباد
    پست
    1,111

    Smile بدست آوردن مقدار یک Enum از عدد متناظر آن

    https://barnamenevis.org/showpo...4&postcount=97

    Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    Dim day As Integer = 3

    Dim d As DaysOfWeek = NumToEnum(Of DaysOfWeek)(day)
    MsgBox(d.ToString)
    End Sub

    Public Function NumToEnum(Of T)(ByVal number As Integer) As T

    Return [Enum].ToObject(GetType(T), number)
    End Function

    Public Enum DaysOfWeek
    Monday
    Tuesday
    Wednesday
    Thursday
    Friday
    Saturday
    Sunday
    End Enum

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •