Fetstil Fetstil Kursiv Understrykning linje färgläggning tabellverk Punktlista Nummerlista Vänster Centrerat högerställt Utfyllt Länk Bild htmlmode
  • Forum & Blog
    • Forum - översikt
      • .Net
        • asp.net generellt
        • c#
        • vb.net
        • f#
        • silverlight
        • microsoft surface
        • visual studio .net
      • databaser
        • sql-server
        • databaser
        • access
        • mysql
      • mjukvara klient
        • datorer och komponenter
        • nätverk, lan/wan
        • operativsystem
        • programvaror
        • säkerhet, inställningar
        • windows server
        • allmänt
        • crystal reports
        • exchange/outlook
        • microsoft office
      • mjukvara server
        • active directory
        • biztalk
        • exchange
        • linux
        • sharepoint
        • webbservers
        • sql server
      • appar (win/mobil)
      • programspråk
        • c++
        • delphi
        • java
        • quick basic
        • visual basic
      • scripting
        • asp 3.0
        • flash actionscript
        • html css
        • javascript
        • php
        • regular expresssion
        • xml
      • spel och grafik
        • DirectX
        • Spel och grafik
      • ledning
        • Arkitektur
        • Systemutveckling
        • krav och test
        • projektledning
        • ledningsfrågor
      • vb-sektioner
        • activeX
        • windows api
        • elektronik
        • internet
        • komponenter
        • nätverk
        • operativsystem
      • övriga forum
        • arbete karriär
        • erbjuda uppdrag och tjänster
        • juridiska frågor
        • köp och sälj
        • matematik och fysik
        • intern information
        • skrivklåda
        • webb-operatörer
    • Posta inlägg i forumet
    • Chatta med andra
  • Konto
    • Medlemssida
    • Byta lösenord
    • Bli bonsumedlem
    • iMail
  • Material
    • Tips & tricks
    • Artiklar
    • Programarkiv
  • JOBB
  • Student
    • Studentlicenser
  • KONTAKT
    • Om pellesoft
    • Grundare
    • Kontakta oss
    • Annonsering
    • Partners
    • Felanmälan
  • Logga in

Hem / Forum översikt / inlägg

Posta nytt inlägg


Rotera en bild

Postades av 2003-09-21 18:40:47 - John Lundberg, i forum visual basic - allmänt, Tråden har 1 Kommentarer och lästs av 449 personer

Hejsan!
Jag har en picture box i en VB app som jag vill kunna rotera i grader.
Är det någon som vet hur man kan göra detta?


Svara

Sv: Rotera en bild

Postades av 2003-09-21 19:22:08 - Sven Åke Persson

<code>
Option Explicit 'Form1
Private Sub Command1_Click()
Call RotateBitmap(Picture1, Picture2, 3.14 / 4)
End Sub

'Modul
Option Explicit
Private Const Pi As Single = 3.14159265358979
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
' Rotate the image in a picture box.
' pic1 is the picture box with the bitmap to rotate
' pic2 is the picture box to receive the rotated bitmap
' theta is the angle of rotation

Sub RotateBitmap(pic1 As PictureBox, pic2 As PictureBox, ByVal theta As Single)
Dim c1x As Long, c1y As Long
Dim c2x As Long, c2y As Long
Dim a As Single
Dim p1x As Long, p1y As Long
Dim p2x As Long, p2y As Long
Dim pic1hDC As Long, pic2hDC As Long
Dim n As Long, r As Long
Dim c0 As Long, c1 As Long, c2 As Long, c3 As Long
Dim xret As Long
c1x = pic1.ScaleX(pic1.ScaleWidth \ 2, pic1.ScaleMode, vbPixels)
c1y = pic1.ScaleX(pic1.ScaleHeight \ 2, pic1.ScaleMode, vbPixels)
c2x = pic2.ScaleX(pic2.ScaleWidth \ 2, pic2.ScaleMode, vbPixels)
c2y = pic2.ScaleX(pic2.ScaleHeight \ 2, pic2.ScaleMode, vbPixels)
If c2x < c2y Then
n = c2y - 1
Else
n = c2x - 1
End If
pic1hDC = pic1.hDC
pic2hDC = pic2.hDC
For p2x = 0 To n
For p2y = 0 To n
If p2x = 0 Then
a = Pi / 2
Else
a = Atn(p2y / p2x)
End If
r = Sqr(p2x * p2x + p2y * p2y)
p1x = r * Cos(a + theta)
p1y = r * Sin(a + theta)
c0 = GetPixel(pic1hDC, c1x + p1x, c1y + p1y)
c1 = GetPixel(pic1hDC, c1x - p1x, c1y - p1y)
c2 = GetPixel(pic1hDC, c1x + p1y, c1y - p1x)
c3 = GetPixel(pic1hDC, c1x - p1y, c1y + p1x)
If c0 <> -1 Then xret = SetPixel(pic2hDC, c2x + p2x, c2y + p2y, c0)
If c1 <> -1 Then xret = SetPixel(pic2hDC, c2x - p2x, c2y - p2y, c1)
If c2 <> -1 Then xret = SetPixel(pic2hDC, c2x + p2y, c2y - p2x, c2)
If c3 <> -1 Then xret = SetPixel(pic2hDC, c2x - p2y, c2y + p2x, c3)
Next
pic2.Refresh
Next
End Sub
</code>


Svara

Nyligen

  • 09:09 Vill du köpa medicinska tester?
  • 12:47 Vem beviljar assistansen – kommune
  • 14:17 Någon med erfarenhet av hemstädnin
  • 14:14 Bör man använda sig av en båtförme
  • 14:12 Finns det någon intressant hundblo
  • 14:25 Tips på verktyg för att skapa QR-k
  • 14:23 Tips på verktyg för att skapa QR-k
  • 20:52 Fungerer innskuddsbonuser egentlig

Sidor

  • Hem
  • Bli bonusmedlem
  • Läs artiklar
  • Chatta med andra
  • Sök och erbjud jobb
  • Kontakta oss
  • Studentlicenser
  • Skriv en artikel

Statistik

Antal besökare:
Antal medlemmar:
Antal inlägg:
Online:
På chatten:
4 569 159
27 952
271 704
919
0

Kontakta oss

Frågor runt konsultation, rådgivning, uppdrag, rekrytering, annonsering och övriga ärenden. Ring: 0730-88 22 24 | pelle@pellesoft.se

© 1986-2013 PelleSoft AB. Last Build 4.1.7169.18070 (2019-08-18 10:02:21) 4.0.30319.42000
  • Om
  • Kontakta
  • Regler
  • Cookies