TARAYICI KODU
#1
Visual Basic
  1. Function GetScan(strFileName As String) As Boolean
  2.  
  3. Dim intRes As Integer
  4. Dim strFormat As String
  5. Dim strFullPath As String
  6. Dim dlg As WIA.CommonDialog
  7. Dim mgr As WIA.DeviceManager
  8. Dim prc As WIA.ImageProcess
  9. Dim dev As WIA.Device
  10. Dim img As WIA.ImageFile
  11. Dim imgFmt As WIA.ImageFile
  12. Dim itm As WIA.Item
  13. Dim prp As WIA.Property
  14. Dim flis As WIA.FilterInfos
  15.  
  16. Set dlg = New WIA.CommonDialog
  17. Set mgr = New WIA.DeviceManager
  18. Set dev = dlg.ShowSelectDevice
  19.  
  20. 'dev.Properties("Document Handling Status") = 1 'can't set this...
  21. 'have not been able to set dev props
  22. 'Debug.Print "##### device properties #####"
  23. 'For Each prp In dev.Properties
  24. ' Debug.Print prp.Name & " = " & prp.Value
  25. 'Next
  26.  
  27. Set itm = dev.Items(1)
  28. 'can only set resolutioin, brightness, and contrast for item properties
  29. intRes = Nz(DLookup("Resolution", "tblPreferences"), 300)
  30. 'itm.Properties("Current Intent") = 4 'why won't TextIntenet (constant= 4) work here?
  31. itm.Properties("Horizontal Resolution") = intRes
  32. itm.Properties("Vertical Resolution") = intRes
  33. itm.Properties("Brightness") = Nz(DLookup("Brightness", "tblPreferences"), 0)
  34. itm.Properties("Contrast") = Nz(DLookup("Contrast", "tblPreferences"), 0)
  35. 'itm.Properties("Media Type") = 2 'can't set this...
  36. 'itm.Properties("Color Profile Name") = "sRGB Color Space Profile.icm" -do I need to set this
  37.  
  38. 'Debug.Print "##### item props #####"
  39. 'For Each prp In itm.Properties
  40. ' Debug.Print prp.Name & " = " & prp.Value
  41. 'Next
  42. 'GoTo Exit_Here
  43.  
  44. Set img = dlg.ShowTransfer(itm)
  45.  
  46. 'the ShowTransfer method returns an ImageFile object in the format
  47. 'specified in FormatID if the device supports that format, otherwise
  48. 'the method uses the preferred format for the imaging device.
  49. 'Apparently, the preferred format of the current scanner is BMP, and
  50. 'FormatID parameter is ignored if we change it, so it is omitted.
  51.  
  52. 'I'm wondering if this is the problem - since I'm scanning a BMP, it'scolor.
  53. 'How do I set the format to something different?
  54.  
  55. Set prc = New WIA.ImageProcess
  56. Set flis = prc.FilterInfos
  57. prc.Filters.Add flis("Convert").FilterID
  58. strFormat = Nz(DLookup("FileFormat", "tblPreferences"), "TIFF")
  59. Select Case strFormat
  60. Case "TIFF"
  61. prc.Filters(1).Properties("FormatID").Value = wiaFormatTIFF
  62. Case "BMP"
  63. prc.Filters(1).Properties("FormatID").Value = wiaFormatBMP
  64. Case "PNG"
  65. prc.Filters(1).Properties("FormatID").Value = wiaFormatPNG
  66. Case "GIF"
  67. prc.Filters(1).Properties("FormatID").Value = wiaFormatGIF
  68. Case "JPEG"
  69. prc.Filters(1).Properties("FormatID").Value = wiaFormatJPEG
  70. End Select
  71. Set imgFmt = prc.Apply(img)
  72. strFullPath = CurrentProject.path & "\" & _
  73. strFileName & "." & imgFmt.FileExtension
  74. imgFmt.SaveFile strFullPath
  75. GetScan = True
  76. Exit_Here:
  77.  
  78. End Function



burda dikkat ettiğiniz gibi fotoğraf referanslarını girdiğiniz bir tablo var tblPreferences diye alanları Resolution=sayı Brightness=sayı Contrast=sayı FileFormat=metin şayet bir çok format girersenizki kod içinde böyle bir seçim yapmanıza izin veriyor ozman bu seçimi yapacak bir form yapmanız lazım bu kodun güzelliği tarayıcı sihirbazını çalıştırmadan tarayıcıdan resim alması istediğiniz ölçü ve renklerde gerçi biz commondiyalog ile tarayıcı yada fotoğraf makinesinden resim alıyrduk ama sihirbaz çalışıyrdu iki işlem oluyordu
kullanımı ise GetScan (Me.AdıSoyadı) bu şekilde resimleri veritabanın bulunduğu yere kaydeder ama siz isterseniz başka bir yerede kaydedebilirsiniz CurrentProject.path kısmı değiştirerek ekteki activex i mutlaka ekleyin yoksa çalışmaz ayrıca bu activex ile vebcamden görüntü capture video kaydetme fotoğraf makinesinden fotoğraf alma ekran capture gibi bir çok işlevi yapabilirsiniz ekindeki yardım dosyasında bir çok özelliği var


Eklenti Dosyaları
.rar   WIAAutSDK.rar (Boyut: 459,84 KB / İndirilme: 315)



  Alıntı
Bu mesajı beğenenler:
#2
Sayın esrefigit;

Öncelikle aramızda bulunduğunuz,katılımınız ve ayrıca verdiğiniz bilgiler ve örnek için çok teşekkür ederiz.

Vermiş olduğunuz örneğin ve bilgilerin önemine binaen konunuzu "Sorular" bölümünden alıp, "Sizin Örnekleriniz" bölümüne taşıdım.

Değerli bilgileriniz ve birikimlerinizden sürekli yararlanabilmek dileğiyle...



  Alıntı
Bu mesajı beğenenler:
#3
Örnek uygulama gönderebilirmisiniz



  Alıntı
Bu mesajı beğenenler:


Benzer Konular...
Konu: Yazar Cevaplar: Gösterim: Son Mesaj
  iki metin kutusundan biri boş ise uyarı versin kodu metocan 1 1.179 07-06-2019, 17:25
Son Mesaj: onur_can

Foruma Git:


Bu konuyu görüntüleyen kullanıcı(lar): 1 Ziyaretçi