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-2024
 
zurück

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

VB.NET - Fortgeschrittene
Re: Problem mit Ausgabe in PictureBox 
Autor: Dikn
Datum: 26.03.18 17:44

Meine Rotationsroutine:

  Private Sub Rotate()
  Dim relPicIn, RelPic2 As Decimal
  Dim inW_half, inH_half As Decimal 
  Dim rotW_half, rotH_half, rotL, rotT As Decimal
  Dim theta As Double =  HScrollBar1.Value * PI / 180.0
    If theta < 0 Then theta *= -1 theta * -1
  Dim sin_theta As Double = Sin(theta)
  Dim cos_theta As Double = Cos(theta)
  inW_half = CDec(bmp_In.Width/2)
  inH_half = CDec(bmp_In.Height/2)
  rotW_half = CDec(Math.Floor(inW_half*cos_theta+inH_half*sin_theta))
  rotH_half = CDec(Math.Floor(inW_half*sin_theta+inH_half*cos_theta))
  rotL = CDec(rotW_half-inW_half*cos_theta+inH_half*sin_theta)
  rotT = CDec(rotH_half-(-inW_half*sin_theta+inH_half*cos_theta))
  bmp_Out = New Bitmap(CInt(2*rotW_half), CInt(2*rotH_half))
  Dim g As Drawing.Graphics = Graphics.FromImage(bmp_Out)
    g.Clear(Color.LightGray)
    Dim p_center As PointF
    p_center.X = rotW_half
    p_center.Y = rotH_half
    Dim m As New Drawing.Drawing2D.Matrix
      m.RotateAt(HScrollBar1.Value, p_center)
      g.Transform = m 
      Dim source_rect As New Rectangle(0, 0, bmp_In.Width, bmp_In.Height)
      Dim intX As Integer = CInt((bmp_Out.Width-bmp_In.Width)/2)
      Dim intY As Integer = CInt((bmp_Out.Height-bmp_In.Height)/2)
      Dim dest_rect As New Rectangle(intX,intY,bmp_In.Width,bmp_In.Height)
      g.DrawImage(bmp_In, dest_rect, source_rect, GraphicsUnit.Pixel)
    m.Dispose()
  g.Dispose()
  pb1.Image = bmp_Out
  RelPic2 = rotT/(2*rotW_half-rotL) 
  relPicIn = CDec(bmp_In.Height/bmp_In.Width)
   If relPicIn < 1 Then
    If relPicIn = pb1.Height/pb1.Width Then 
      out_rect.Width = CInt(Math.Floor(2*(rotH_half-rotT+rotW_half*RelPic2)/( _
        relPicIn+RelPic2)/16)*16)
    Else
      out_rect.Width = CInt(Math.Floor(2*(rotH_half-rotT+rotW_half*RelPic2)/( _
        relPicIn+RelPic2)))
    End                             |
    out_rect.Height = CInt(Math.Floor(out_rect.Width*relPicIn))
  Else
    out_rect.Height = CInt((2*(rotW_half-rotL+rotH_half*RelPic2)/( _
      bmp_In.Width/bmp_In.Height+RelPic2)))
    out_rect.Width = CInt((out_rect.Height/relPicIn))
  End If 
  out_rect.X = CInt(rotW_half-out_rect.Width/2)
  out_rect.y =  CInt(rotH_half-out_rect.Height/2)
  If bmp_Out.Height/bmp_Out.Width > pb1.Height/pb1.Width Then
    decZoom = CDec(bmp_Out.Height/pb1.Height)
  Else
    decZoom = CDec(bmp_Out.Width/pb1.Width)
  End If  
  If pb1.SizeMode = PictureBoxSizeMode.CenterImage Then decZoom = 1
  Dim ImagePart As Bitmap = New Bitmap(out_rect.Width, out_rect.Height)
  g = Graphics.FromImage(ImagePart)
    Dim TargetRect As Rectangle = New Rectangle(0, 0, out_rect.Width, _
      out_rect.Height)
    g.DrawImage(bmp_Out, TargetRect, out_rect, GraphicsUnit.Pixel)
  g.Dispose
  g = Nothing
  pb2.Image = ImagePart         
  If chbVollbild.Checked = True Then pb1.Image = ImagePart
  End Sub
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Problem mit Ausgabe in PictureBox2.957Dikn23.03.18 18:29
Re: Problem mit Ausgabe in PictureBox2.111Manfred X23.03.18 20:15
Re: Problem mit Ausgabe in PictureBox2.067Kuno6023.03.18 20:44
Re: Problem mit Ausgabe in PictureBox2.030Dikn25.03.18 10:10
Re: Problem mit Ausgabe in PictureBox2.074Manfred X25.03.18 12:48
Re: Problem mit Ausgabe in PictureBox2.053Dikn26.03.18 08:36
Re: Problem mit Ausgabe in PictureBox2.084Kuno6027.03.18 16:29
Re: Problem mit Ausgabe in PictureBox2.020Dikn26.03.18 09:58
Re: Problem mit Ausgabe in PictureBox2.038Manfred X26.03.18 11:26
Re: Problem mit Ausgabe in PictureBox2.033Dikn26.03.18 17:44
Re: Problem mit Ausgabe in PictureBox2.167Manfred X26.03.18 18:32
Re: Problem mit Ausgabe in PictureBox2.002Dikn27.03.18 09:22
Re: Problem mit Ausgabe in PictureBox2.151Manfred X27.03.18 09:33
Re: Problem mit Ausgabe in PictureBox1.986Dikn28.03.18 12:03
Re: Problem mit Ausgabe in PictureBox2.005Kuno6028.03.18 15:17
Re: Problem mit Ausgabe in PictureBox2.054Dikn28.03.18 18:01
Re: Problem mit Ausgabe in PictureBox1.976Kuno6004.04.18 07:06
Re: Problem mit Ausgabe in PictureBox1.926Manfred X04.04.18 13:37
Re: Problem mit Ausgabe in PictureBox1.868Kuno6004.04.18 20:18
Re: Problem mit Ausgabe in PictureBox1.838Manfred X04.04.18 20:51
Re: Problem mit Ausgabe in PictureBox1.900Kuno6004.04.18 21:10
Re: Problem mit Ausgabe in PictureBox1.901Manfred X04.04.18 21:40
Re: Problem mit Ausgabe in PictureBox1.819Kuno6004.04.18 22:52
Re: Problem mit Ausgabe in PictureBox1.864Manfred X04.04.18 23:02
Re: Problem mit Ausgabe in PictureBox1.850Kuno6004.04.18 23:20
Re: Problem mit Ausgabe in PictureBox1.893Manfred X04.04.18 23:33

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-2024 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