vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
NEU! sevCoolbar 3.0 - Professionelle Toolbars im modernen Design!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Visual-Basic Einsteiger
Re: SavePicture bmp in jpeg 
Autor: Binthom
Datum: 03.11.06 11:50

Hier der Code aus meinem JPG-Modul:
einfach eine Picturebox angeben und das bild wird mit der Funktion gespeichert!


Option Explicit
 
' Zunächst die nötigen Deklarationen
Private Type GUID
  Data1 As Long
  Data2 As Integer
  Data3 As Integer
  Data4(0 To 7) As Byte
End Type
 
Private Type GdiplusStartupInput
  GdiplusVersion As Long
  DebugEventCallback As Long
  SuppressBackgroundThread As Long
  SuppressExternalCodecs As Long
End Type
 
Private Type EncoderParameter
  GUID As GUID
  NumberOfValues As Long
  type As Long
  Value As Long
End Type
 
Private Type EncoderParameters
  Count As Long
  Parameter As EncoderParameter
End Type
 
Private Declare Function GdiplusStartup Lib "GDIPlus" ( _
  token As Long, _
  inputbuf As GdiplusStartupInput, _
  Optional ByVal outputbuf As Long = 0) As Long
 
Private Declare Function GdiplusShutdown Lib "GDIPlus" ( _
  ByVal token As Long) As Long
 
Private Declare Function GdipCreateBitmapFromHBITMAP Lib "GDIPlus" ( _
  ByVal hbm As Long, _
  ByVal hpal As Long, _
  Bitmap As Long) As Long
 
Private Declare Function GdipDisposeImage Lib "GDIPlus" ( _
  ByVal Image As Long) As Long
 
Private Declare Function GdipSaveImageToFile Lib "GDIPlus" ( _
  ByVal Image As Long, _
  ByVal filename As Long, _
  clsidEncoder As GUID, _
  encoderParams As Any) As Long
 
Private Declare Function CLSIDFromString Lib "ole32" ( _
  ByVal str As Long, _
  id As GUID) As Long
 
Public Sub Save_JPG(PictureBoxObjekt As PictureBox, ByVal filename As String, _
  Optional ByVal quality As Byte = 200)
 
  Dim tSI As GdiplusStartupInput
  Dim lRes As Long
  Dim lGDIP As Long
  Dim lBitmap As Long
 
  Dim pict As New StdPicture
  Set pict = PictureBoxObjekt.Picture
 
  ' GDI+ initalisieren
  tSI.GdiplusVersion = 1
  lRes = GdiplusStartup(lGDIP, tSI)
 
  If lRes = 0 Then
    '  Erstelle GDI+ Bitmap aus dem Image Handler
    lRes = GdipCreateBitmapFromHBITMAP(pict.Handle, 0, lBitmap)
 
    If lRes = 0 Then
      Dim tJpgEncoder As GUID
      Dim tParams As EncoderParameters
 
      ' Initialiseren des Encoders
      CLSIDFromString StrPtr("{557CF401-1A04-11D3-9A73-0000F81EF32E}"), _
        tJpgEncoder
 
      ' Nun die Parametrierung...
      tParams.Count = 1
      With tParams.Parameter ' Quality
        ' Quality GUID festlegen
        CLSIDFromString StrPtr("{1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}"), .GUID
        .NumberOfValues = 1
        .type = 4
        .Value = VarPtr(quality)
      End With
 
      ' Speichern des Bildes
      lRes = GdipSaveImageToFile(lBitmap, StrPtr(filename), tJpgEncoder, _
        tParams)
 
      ' Zerstören des Bildes
      GdipDisposeImage lBitmap
    End If
 
    ' GDI+ deinitalisieren
    GdiplusShutdown lGDIP
  End If
 
  If lRes Then
  Exit Sub
  End If
End Sub
Ich hoffe das bringt dir was Du solltest den ganzen Code am Besten auch in ein Modul speichern...

Liebe Grüße,
Binthom
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
SavePicture bmp in jpeg3.167LeaLina01.11.06 09:47
Re: SavePicture bmp in jpeg1.554Zardoz01.11.06 11:08
Re: SavePicture bmp in jpeg1.280LeaLina01.11.06 11:31
Re: SavePicture bmp in jpeg1.247Zardoz01.11.06 12:00
Re: SavePicture bmp in jpeg1.199LeaLina01.11.06 13:19
Re: SavePicture bmp in jpeg1.248Zardoz01.11.06 13:37
Re: SavePicture bmp in jpeg1.165LeaLina01.11.06 14:43
Re: SavePicture bmp in jpeg1.172Zardoz01.11.06 16:48
Re: SavePicture bmp in jpeg1.134LeaLina02.11.06 11:11
Re: SavePicture bmp in jpeg1.100LeaLina02.11.06 11:39
Re: SavePicture bmp in jpeg1.116Zardoz02.11.06 16:46
Re: SavePicture bmp in jpeg1.140LeaLina03.11.06 08:39
Re: SavePicture bmp in jpeg1.092Zardoz03.11.06 15:36
Re: SavePicture bmp in jpeg1.100LeaLina06.11.06 10:01
Re: SavePicture bmp in jpeg1.058LeaLina07.11.06 14:31
Re: SavePicture bmp in jpeg1.089Zardoz07.11.06 22:18
Re: SavePicture bmp in jpeg1.102LeaLina08.11.06 11:16
Re: SavePicture bmp in jpeg1.125LeaLina08.11.06 12:17
Re: SavePicture bmp in jpeg1.120LeaLina10.11.06 08:25
Re: SavePicture bmp in jpeg1.090Zardoz10.11.06 11:46
Re: SavePicture bmp in jpeg1.166LeaLina13.11.06 10:13
Re: SavePicture bmp in jpeg1.154LeaLina13.11.06 11:09
Re: SavePicture bmp in jpeg1.200HaZzard01.11.06 11:13
Re: SavePicture bmp in jpeg1.151HaZzard01.11.06 11:15
Re: SavePicture bmp in jpeg1.121LeaLina01.11.06 11:39
Re: SavePicture bmp in jpeg1.477Binthom03.11.06 11:50
Re: SavePicture bmp in jpeg1.147LeaLina06.11.06 10:03

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel