vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Mails senden, abrufen und decodieren - ganz easy ;-)  
 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

Fortgeschrittene Programmierung
Re: Picture 90 Grad drehen 
Autor: ModeratorDieter (Moderator)
Datum: 30.09.01 22:28

Hallo Dany,

hierzu brauchst Du folgenden Code:
<code><font color=green>' zunächst die benötigten API-Deklarationen</font>
 
Private Declare Function SetPixel Lib "gdi32" _
  (ByVal hdc As Long, ByVal x As Long, _
  ByVal y As Long, ByVal crColor As Long) As Long
 
Private Declare Function GetPixel Lib "gdi32" _
  (ByVal hdc As Long, ByVal x As Long, _
  ByVal y As Long) As Long
 
Private Declare Function StretchBlt Lib "gdi32" _
  (ByVal hdc As Long, ByVal x As Long, _
  ByVal y As Long, ByVal nWidth As Long, _
  ByVal nHeight As Long, ByVal hSrcDC As Long, _
  ByVal xSrc As Long, ByVal ySrc As Long, _
  ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, _
  ByVal dwRop As Long) As Long
 
Const SRCCOPY = &HCC0020
Const Pi = 3.14159265359
 
<font color=green>' PictureBox drehen</font>
Sub RotatePicture(picSource As PictureBox, _
  picDest As PictureBox, ByVal Winkel As Single)
 
  <font color=green>' Drehen eines Bildes einer PictureBox
  ' und Anzeige des Bildes in einer zweiten PictureBox</font>
 
  <font color=green>' cp0 - cp3 = Farbe eines einzelnen Pixels</font>
  Dim cp0 As Long, cp1 As Long
  Dim cp2 As Long, cp3 As Long
 
  <font color=green>' Pixel-Koordinaten</font>
  Dim c1x As Long, c1y As Long
  Dim c2x As Long, c2y As Long
 
  <font color=green>' Geräte-Kontext der beiden PictureBoxen</font>
  Dim p1hDC As Long
  Dim p2hDC As Long
 
  Dim a As Single
  Dim p1x As Long, p1y As Long
  Dim p2x As Long, p2y As Long
  Dim n As Long, r As Long
 
  c1x = picSource.ScaleWidth  2
  c1y = picSource.ScaleHeight  2
  c2x = picDest.ScaleWidth  2
  c2y = picDest.ScaleHeight  2
 
  If c2x < c2y Then n = c2y Else n = c2x
  n = n - 1
  p1hDC = picSource.hdc
  p2hDC = picDest.hdc
 
  For p2x = 0 To n
    For p2y = 0 To n
      If p2x = 0 Then a = Pi / 2 Else a = Atn(p2y / p2x)
      r = Sqr(p2x * p2x + p2y * p2y)
      p1x = r * Cos(a + Winkel)
      p1y = r * Sin(a + Winkel)
      cp0 = GetPixel(p1hDC, c1x + p1x, c1y + p1y)
      cp1 = GetPixel(p1hDC, c1x - p1x, c1y - p1y)
      cp2 = GetPixel(p1hDC, c1x + p1y, c1y - p1x)
      cp3 = GetPixel(p1hDC, c1x - p1y, c1y + p1x)
      If cp0 <> -1 Then SetPixel p2hDC, c2x + p2x, c2y + p2y, cp0
      If cp1 <> -1 Then SetPixel p2hDC, c2x - p2x, c2y - p2y, cp1
       If cp2 <> -1 Then SetPixel p2hDC, c2x + p2y, c2y - p2x, cp2
      If cp3 <> -1 Then SetPixel p2hDC, c2x - p2y, c2y + p2x, cp3
    Next p2y
  Next p2x
End Sub</code>
Die Vorgehensweise ist folgende:
Du benötigst neben der Quell-PictureBox noch eine zweite - die Ziel-PictureBox, welche das gedrehte Bild enthalten soll.

Der Aufruf ist ganz einfach:
<code>RotatePicture Picture1, Picture2, PI / 2</code>
Viel Spass damit!

Cu
Dieter
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Picture 90 Grad drehen38Dany30.09.01 14:47
Re: Picture 90 Grad drehen369ModeratorDieter30.09.01 22:28
Re: Picture 90 Grad drehen22Dany30.09.01 22:37
Frage komisch19Dany30.09.01 22:48
2. Frage18Dany30.09.01 22:49
Re: 2. Frage237ModeratorDieter30.09.01 22:53
Aha Thanks Dieter15Dany30.09.01 22:56
Warten Warten14Dany30.09.01 23:08
WIe geht das ?16Dany30.09.01 23:09
Ganz genau.273ModeratorDieter30.09.01 23:12
hahaha15Dany30.09.01 23:16

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