الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

الى الخبراء ... ارجووو المساعده .. ابي طود Open و Save للpictuerbox

بدأه talalov في 8 يونيو 2008 · 2 رد · 659 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلااام عليكم

ارجووو المسااااعده من الخبراء

انا استخدم vb.net 2003

ابي كوود save and open

لل picturebox

ضروري

...........................................

انا اعرف الكود save and open لل text

بس ما رضى يخزن الصور؟؟؟؟؟؟؟

#2

الكود التالي ممكن يساعدك


Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

public class PictureBoxImageFromOpenFileDialog
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class

Public Class Form1
Inherits System.Windows.Forms.Form

Public Sub New()
MyBase.New()

InitializeComponent()

End Sub

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

Private components As System.ComponentModel.IContainer

Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.Button1 = New System.Windows.Forms.Button
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
Me.SuspendLayout()
'
'PictureBox1
'
Me.PictureBox1.Location = New System.Drawing.Point(16, 16)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(248, 176)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
Me.PictureBox1.TabIndex = 0
Me.PictureBox1.TabStop = False
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(96, 208)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(88, 24)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Open"
'
'OpenFileDialog1
'
Me.OpenFileDialog1.Filter = "bmp(*.bmp)|*.bmp"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.PictureBox1)
Me.ResumeLayout(False)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pic As Image
OpenFileDialog1.ShowDialog()
pic = New Bitmap(OpenFileDialog1.FileName)
PictureBox1.Image = pic
End Sub
End Class
Imports System.Drawing

بالتوفيق

اخوك عمر

تم تعديل هذه المشاركة بواسطة a_pess في 8 يونيو 2008 في 12:09

#3

ابي تعديل في هالكود

هذا الكود مالي استخدمه في البوكت بي سي

في الفيجوال بيسك

Public Class Form1

Inherits System.Windows.Forms.Form

Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox

Friend WithEvents PictureBox2 As System.Windows.Forms.PictureBox

Friend WithEvents PictureBox3 As System.Windows.Forms.PictureBox

Friend WithEvents PictureBox4 As System.Windows.Forms.PictureBox

Friend WithEvents PictureBox5 As System.Windows.Forms.PictureBox

Friend WithEvents op As System.Windows.Forms.OpenFileDialog

Friend WithEvents sa As System.Windows.Forms.SaveFileDialog

Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem

Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu

Dim x1, y1, x2, y2 As Integer

Dim p = New Pen(Color.Yellow)

Dim pw As Integer = 7

Dim col As Color = Color.White

Dim bmp As System.Drawing.Bitmap

Dim down As Boolean = False

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

MyBase.Dispose(disposing)

End Sub

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox

Friend WithEvents Label1 As System.Windows.Forms.Label

Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem

Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem

Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem

Friend WithEvents PictureBox6 As System.Windows.Forms.PictureBox

Friend WithEvents PictureBox7 As System.Windows.Forms.PictureBox

Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem

Friend WithEvents MenuItem6 As System.Windows.Forms.MenuItem

Friend WithEvents PictureBox8 As System.Windows.Forms.PictureBox

Private Sub InitializeComponent()

Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))

Me.MainMenu1 = New System.Windows.Forms.MainMenu

Me.MenuItem1 = New System.Windows.Forms.MenuItem

Me.MenuItem3 = New System.Windows.Forms.MenuItem

Me.MenuItem4 = New System.Windows.Forms.MenuItem

Me.MenuItem5 = New System.Windows.Forms.MenuItem

Me.MenuItem6 = New System.Windows.Forms.MenuItem

Me.PictureBox1 = New System.Windows.Forms.PictureBox

Me.PictureBox2 = New System.Windows.Forms.PictureBox

Me.PictureBox3 = New System.Windows.Forms.PictureBox

Me.PictureBox4 = New System.Windows.Forms.PictureBox

Me.PictureBox5 = New System.Windows.Forms.PictureBox

Me.MenuItem2 = New System.Windows.Forms.MenuItem

Me.ComboBox1 = New System.Windows.Forms.ComboBox

Me.Label1 = New System.Windows.Forms.Label

Me.PictureBox6 = New System.Windows.Forms.PictureBox

Me.PictureBox7 = New System.Windows.Forms.PictureBox

Me.PictureBox8 = New System.Windows.Forms.PictureBox

'

'MainMenu1

'

Me.MainMenu1.MenuItems.Add(Me.MenuItem1)

'

'MenuItem1

'

Me.MenuItem1.MenuItems.Add(Me.MenuItem3)

Me.MenuItem1.MenuItems.Add(Me.MenuItem4)

Me.MenuItem1.MenuItems.Add(Me.MenuItem5)

Me.MenuItem1.MenuItems.Add(Me.MenuItem6)

Me.MenuItem1.Text = "File"

'

'MenuItem3

'

Me.MenuItem3.Text = "open"

'

'MenuItem4

'

Me.MenuItem4.Text = "New"

'

'MenuItem5

'

Me.MenuItem5.Text = "Close"

'

'MenuItem6

'

Me.MenuItem6.Text = "Save As"

'

'PictureBox1

'

Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)

Me.PictureBox1.Location = New System.Drawing.Point(72, 8)

Me.PictureBox1.Size = New System.Drawing.Size(152, 184)

'

'PictureBox2

'

Me.PictureBox2.Image = CType(resources.GetObject("PictureBox2.Image"), System.Drawing.Image)

Me.PictureBox2.Location = New System.Drawing.Point(8, 8)

Me.PictureBox2.Size = New System.Drawing.Size(24, 24)

'

'PictureBox3

'

Me.PictureBox3.Image = CType(resources.GetObject("PictureBox3.Image"), System.Drawing.Image)

Me.PictureBox3.Location = New System.Drawing.Point(8, 40)

Me.PictureBox3.Size = New System.Drawing.Size(24, 24)

'

'PictureBox4

'

Me.PictureBox4.Image = CType(resources.GetObject("PictureBox4.Image"), System.Drawing.Image)

Me.PictureBox4.Location = New System.Drawing.Point(8, 72)

Me.PictureBox4.Size = New System.Drawing.Size(24, 24)

'

'PictureBox5

'

Me.PictureBox5.Image = CType(resources.GetObject("PictureBox5.Image"), System.Drawing.Image)

Me.PictureBox5.Location = New System.Drawing.Point(8, 104)

Me.PictureBox5.Size = New System.Drawing.Size(24, 24)

'

'MenuItem2

'

Me.MenuItem2.Text = ""

'

'ComboBox1

'

Me.ComboBox1.Items.Add("")

Me.ComboBox1.Items.Add("1")

Me.ComboBox1.Items.Add("2")

Me.ComboBox1.Items.Add("3")

Me.ComboBox1.Items.Add("4")

Me.ComboBox1.Items.Add("5")

Me.ComboBox1.Items.Add("6")

Me.ComboBox1.Items.Add("7")

Me.ComboBox1.Items.Add("8")

Me.ComboBox1.Items.Add("9")

Me.ComboBox1.Items.Add("10")

Me.ComboBox1.Items.Add("11")

Me.ComboBox1.Items.Add("12")

Me.ComboBox1.Items.Add("13")

Me.ComboBox1.Location = New System.Drawing.Point(184, 240)

Me.ComboBox1.Size = New System.Drawing.Size(48, 21)

'

'Label1

'

Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold)

Me.Label1.Location = New System.Drawing.Point(64, 240)

Me.Label1.Text = "Brush zise"

'

'PictureBox6

'

Me.PictureBox6.Image = CType(resources.GetObject("PictureBox6.Image"), System.Drawing.Image)

Me.PictureBox6.Location = New System.Drawing.Point(8, 136)

Me.PictureBox6.Size = New System.Drawing.Size(24, 24)

'

'PictureBox7

'

Me.PictureBox7.Image = CType(resources.GetObject("PictureBox7.Image"), System.Drawing.Image)

Me.PictureBox7.Location = New System.Drawing.Point(8, 168)

Me.PictureBox7.Size = New System.Drawing.Size(24, 24)

'

'PictureBox8

'

Me.PictureBox8.Image = CType(resources.GetObject("PictureBox8.Image"), System.Drawing.Image)

Me.PictureBox8.Location = New System.Drawing.Point(8, 200)

Me.PictureBox8.Size = New System.Drawing.Size(24, 24)

'

'Form1

'

Me.BackColor = System.Drawing.Color.Gray

Me.Controls.Add(Me.PictureBox8)

Me.Controls.Add(Me.PictureBox7)

Me.Controls.Add(Me.PictureBox6)

Me.Controls.Add(Me.Label1)

Me.Controls.Add(Me.ComboBox1)

Me.Controls.Add(Me.PictureBox5)

Me.Controls.Add(Me.PictureBox4)

Me.Controls.Add(Me.PictureBox3)

Me.Controls.Add(Me.PictureBox2)

Me.Controls.Add(Me.PictureBox1)

Me.Menu = Me.MainMenu1

Me.Text = "Form1"

End Sub

#End Region

Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click

End Sub

Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem6.Click

Dim sfd As New SaveFileDialog

sfd.Filter = "bitmap(*.bmp)|*.bmp"

sfd.ShowDialog()

If sfd.FileName = "" Then

MsgBox("please Enter avalid file Name")

Else

Dim fs As New System.IO.StreamWriter(sfd.FileName)

fs.WriteLine(bmp)

fs.Close()

End If

End Sub

Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click

Dim op As New OpenFileDialog

op.ShowDialog()

Dim bm As New Bitmap(op.FileName)

PictureBox1.Image = bm

End Sub

Private Sub PictureBox2_ParentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.ParentChanged

End Sub

Private Sub PictureBox2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.Click

col = Color.Red

End Sub

Private Sub PictureBox7_ParentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox7.ParentChanged

End Sub

Private Sub PictureBox3_ParentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.ParentChanged

End Sub

Private Sub PictureBox3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox3.Click

col = Color.Green

End Sub

Private Sub PictureBox4_ParentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox4.ParentChanged

End Sub

Private Sub PictureBox4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox4.Click

col = Color.Black

End Sub

Private Sub PictureBox5_ParentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox5.ParentChanged

End Sub

Private Sub PictureBox5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox5.Click

col = Color.Pink

End Sub

Private Sub PictureBox6_ParentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox6.ParentChanged

End Sub

Private Sub PictureBox6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox6.Click

col = Color.Blue

End Sub

Private Sub PictureBox7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox7.Click

col = Color.Yellow

End Sub

Private Sub PictureBox8_ParentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox8.ParentChanged

End Sub

Private Sub PictureBox8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox8.Click

col = Color.White

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim bmp1 As New Bitmap(PictureBox1.Width, PictureBox1.Height)

PictureBox1.Image = bmp1

End Sub

Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click

End Sub

Private Sub PictureBox1_ParentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.ParentChanged

End Sub

Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown

x1 = e.X

y1 = e.Y

down = True

End Sub

Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove

If down = True Then

x2 = e.X

y2 = e.Y

bmp = New Bitmap(PictureBox1.Image)

p = New Pen(col)

Dim g As Graphics = Graphics.FromImage(bmp)

g.DrawLine(p, x1, y1, x2, y2)

PictureBox1.Image = bmp

g.Dispose()

x1 = x2

y1 = y2

x2 = e.X

y2 = e.Y

End If

End Sub

Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp

down = False

End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

pw = ComboBox1.Text

End Class

تم تعديل هذه المشاركة بواسطة talalov في 9 يونيو 2008 في 00:53

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…