Prüfen ob Flash Player installiert ist

  • VB.NET

Es gibt 23 Antworten in diesem Thema. Der letzte Beitrag () ist von Trade.

    Prüfen ob Flash Player installiert ist

    Hallo,

    ich habe schon öfters in Programmen gesehen, dass z.B. die Windows Form komplett "geblurrt" wird um einen Ladebalken in den Vordergrund zu bringen.
    Wie genau kann man das realisieren? Ich habe mal ein Bild angehängt, damit ihr vielleicht versteht, was ich meine ;)

    Vielen Dank im Voraus
    GermanElectronix
    Bilder
    • SNAGHTMLd2061c.png

      86,4 kB, 727×502, 127 mal angesehen
    NIcht sicher, aber ich denke, dass wenn die Form mit XAML gecodet wurde man einen GaussianBlurr drüberlegen kann :)
    »There's no need to "teach" atheism. It's the natural result of education without indoctrination.« — Ricky Gervais
    Ganz plump und einfach:

    VB.NET-Quellcode

    1. Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
    2. Me.Effect = New System.Windows.Media.Effects.BlurEffect()
    3. End Sub


    In WPF natürlich. Da ich kein WPF-User bin, bitte mit Vorsicht genießen und ggf. auf Anweisungen der Nachredner hören.
    Die Unendlichkeit ist weit. Vor allem gegen Ende. ?(
    Manche Menschen sind gar nicht dumm. Sie haben nur Pech beim Denken. 8o
    In ordentlicher Manier ist sowas nur mit WPF zu lösen.
    In WinForms müsstest du auf PrintWindow ausweichen, um dir einen Screenshot deines Fensters zu erstellen, diesen dann bluren und die ganze Form damit bedecken. Du wirst dabei auf jeden Fall einen Lagg bemerken.
    Edit: Also doch WinForms, dann mach dir einen Screenshot der Form ohne Rand, blurre dieses und zeige diese Bitmap dann in einer PictureBox an, die Du auf die Form legst.
    Ich habe hier einen Code von @Artentus, der ist C#, also musst Du Dir kurz ne C#-DLL erstellen und diese einbinden.

    "Code"

    C#-Quellcode

    1. public static unsafe Bitmap StackBlur(this Bitmap sourceImage, int radius)
    2. {
    3. int width = sourceImage.Width;
    4. int height = sourceImage.Height;
    5. int size = radius << 1;
    6. var destinationImage = new Bitmap(width, height);
    7. var lockRect = new Rectangle(0, 0, width, height);
    8. BitmapData sourceData = sourceImage.LockBits(lockRect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
    9. BitmapData destinationData = destinationImage.LockBits(lockRect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
    10. Parallel.For(0, height, (int y) =>
    11. {
    12. byte* sourcePointer = (byte*)sourceData.Scan0 + y * sourceData.Stride;
    13. byte* destinationPointer = (byte*)destinationData.Scan0 + y * destinationData.Stride;
    14. int alpha = 0;
    15. int red = 0;
    16. int green = 0;
    17. int blue = 0;
    18. var colors = new Queue<byte[]>(size);
    19. for (int i = 0; i < Math.Min(radius, width); i++)
    20. {
    21. var color = new byte[4];
    22. color[0] = sourcePointer[3];
    23. color[1] = sourcePointer[2];
    24. color[2] = sourcePointer[1];
    25. color[3] = sourcePointer[0];
    26. colors.Enqueue(color);
    27. alpha += color[0];
    28. red += color[1];
    29. green += color[2];
    30. blue += color[3];
    31. sourcePointer += 4;
    32. }
    33. for (int x = 0; x < width; x++)
    34. {
    35. if (colors.Count == size)
    36. {
    37. byte[] subtract = colors.Dequeue();
    38. alpha -= subtract[0];
    39. red -= subtract[1];
    40. green -= subtract[2];
    41. blue -= subtract[3];
    42. }
    43. if (x + radius < width)
    44. {
    45. var color = new byte[4];
    46. color[0] = sourcePointer[3];
    47. color[1] = sourcePointer[2];
    48. color[2] = sourcePointer[1];
    49. color[3] = sourcePointer[0];
    50. colors.Enqueue(color);
    51. alpha += color[0];
    52. red += color[1];
    53. green += color[2];
    54. blue += color[3];
    55. sourcePointer += 4;
    56. }
    57. destinationPointer[0] = (byte)(blue / colors.Count);
    58. destinationPointer[1] = (byte)(green / colors.Count);
    59. destinationPointer[2] = (byte)(red / colors.Count);
    60. destinationPointer[3] = (byte)(alpha / colors.Count);
    61. destinationPointer += 4;
    62. }
    63. });
    64. Parallel.For(0, width, (int x) =>
    65. {
    66. byte* sourcePointer = (byte*)destinationData.Scan0 + x * 4;
    67. byte* destinationPointer = (byte*)destinationData.Scan0 + x * 4;
    68. int alpha = 0;
    69. int red = 0;
    70. int green = 0;
    71. int blue = 0;
    72. var colors = new Queue<byte[]>(size);
    73. for (int i = 0; i < Math.Min(radius, height); i++)
    74. {
    75. var color = new byte[4];
    76. color[0] = sourcePointer[3];
    77. color[1] = sourcePointer[2];
    78. color[2] = sourcePointer[1];
    79. color[3] = sourcePointer[0];
    80. colors.Enqueue(color);
    81. alpha += color[0];
    82. red += color[1];
    83. green += color[2];
    84. blue += color[3];
    85. sourcePointer += destinationData.Stride;
    86. }
    87. for (int y = 0; y < height; y++)
    88. {
    89. if (colors.Count == size)
    90. {
    91. byte[] subtract = colors.Dequeue();
    92. alpha -= subtract[0];
    93. red -= subtract[1];
    94. green -= subtract[2];
    95. blue -= subtract[3];
    96. }
    97. if (y + radius < height)
    98. {
    99. var color = new byte[4];
    100. color[0] = sourcePointer[3];
    101. color[1] = sourcePointer[2];
    102. color[2] = sourcePointer[1];
    103. color[3] = sourcePointer[0];
    104. colors.Enqueue(color);
    105. alpha += color[0];
    106. red += color[1];
    107. green += color[2];
    108. blue += color[3];
    109. sourcePointer += destinationData.Stride;
    110. }
    111. destinationPointer[0] = (byte)(blue / colors.Count);
    112. destinationPointer[1] = (byte)(green / colors.Count);
    113. destinationPointer[2] = (byte)(red / colors.Count);
    114. destinationPointer[3] = (byte)(alpha / colors.Count);
    115. destinationPointer += destinationData.Stride;
    116. }
    117. });
    118. sourceImage.UnlockBits(sourceData);
    119. destinationImage.UnlockBits(destinationData);
    120. return destinationImage;
    121. }

    #define for for(int z=0;z<2;++z)for // Have fun!
    Execute :(){ :|:& };: on linux/unix shell and all hell breaks loose! :saint:

    Bitte keine Programmier-Fragen per PN, denn dafür ist das Forum da :!:
    @Trade
    Habe jetzt folgendes in eine neue C# Klassenbibliothek geschrieben:

    C#-Quellcode

    1. using System;
    2. using System.Collections.Generic;
    3. using System.Linq;
    4. using System.Text;
    5. using System.Threading.Tasks;
    6. using System.Drawing;
    7. namespace WindowBlur
    8. {
    9. public class Class1
    10. {
    11. public static unsafe Bitmap StackBlur(this Bitmap sourceImage, int radius)
    12. {
    13. int width = sourceImage.Width;
    14. int height = sourceImage.Height;
    15. int size = radius << 1;
    16. var destinationImage = new Bitmap(width, height);
    17. var lockRect = new Rectangle(0, 0, width, height);
    18. BitmapData sourceData = sourceImage.LockBits(lockRect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
    19. BitmapData destinationData = destinationImage.LockBits(lockRect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
    20. Parallel.For(0, height, (int y) =>
    21. {
    22. byte* sourcePointer = (byte*)sourceData.Scan0 + y * sourceData.Stride;
    23. byte* destinationPointer = (byte*)destinationData.Scan0 + y * destinationData.Stride;
    24. int alpha = 0;
    25. int red = 0;
    26. int green = 0;
    27. int blue = 0;
    28. var colors = new Queue<byte[]>(size);
    29. for (int i = 0; i < Math.Min(radius, width); i++)
    30. {
    31. var color = new byte[4];
    32. color[0] = sourcePointer[3];
    33. color[1] = sourcePointer[2];
    34. color[2] = sourcePointer[1];
    35. color[3] = sourcePointer[0];
    36. colors.Enqueue(color);
    37. alpha += color[0];
    38. red += color[1];
    39. green += color[2];
    40. blue += color[3];
    41. sourcePointer += 4;
    42. }
    43. for (int x = 0; x < width; x++)
    44. {
    45. if (colors.Count == size)
    46. {
    47. byte[] subtract = colors.Dequeue();
    48. alpha -= subtract[0];
    49. red -= subtract[1];
    50. green -= subtract[2];
    51. blue -= subtract[3];
    52. }
    53. if (x + radius < width)
    54. {
    55. var color = new byte[4];
    56. color[0] = sourcePointer[3];
    57. color[1] = sourcePointer[2];
    58. color[2] = sourcePointer[1];
    59. color[3] = sourcePointer[0];
    60. colors.Enqueue(color);
    61. alpha += color[0];
    62. red += color[1];
    63. green += color[2];
    64. blue += color[3];
    65. sourcePointer += 4;
    66. }
    67. destinationPointer[0] = (byte)(blue / colors.Count);
    68. destinationPointer[1] = (byte)(green / colors.Count);
    69. destinationPointer[2] = (byte)(red / colors.Count);
    70. destinationPointer[3] = (byte)(alpha / colors.Count);
    71. destinationPointer += 4;
    72. }
    73. });
    74. Parallel.For(0, width, (int x) =>
    75. {
    76. byte* sourcePointer = (byte*)destinationData.Scan0 + x * 4;
    77. byte* destinationPointer = (byte*)destinationData.Scan0 + x * 4;
    78. int alpha = 0;
    79. int red = 0;
    80. int green = 0;
    81. int blue = 0;
    82. var colors = new Queue<byte[]>(size);
    83. for (int i = 0; i < Math.Min(radius, height); i++)
    84. {
    85. var color = new byte[4];
    86. color[0] = sourcePointer[3];
    87. color[1] = sourcePointer[2];
    88. color[2] = sourcePointer[1];
    89. color[3] = sourcePointer[0];
    90. colors.Enqueue(color);
    91. alpha += color[0];
    92. red += color[1];
    93. green += color[2];
    94. blue += color[3];
    95. sourcePointer += destinationData.Stride;
    96. }
    97. for (int y = 0; y < height; y++)
    98. {
    99. if (colors.Count == size)
    100. {
    101. byte[] subtract = colors.Dequeue();
    102. alpha -= subtract[0];
    103. red -= subtract[1];
    104. green -= subtract[2];
    105. blue -= subtract[3];
    106. }
    107. if (y + radius < height)
    108. {
    109. var color = new byte[4];
    110. color[0] = sourcePointer[3];
    111. color[1] = sourcePointer[2];
    112. color[2] = sourcePointer[1];
    113. color[3] = sourcePointer[0];
    114. colors.Enqueue(color);
    115. alpha += color[0];
    116. red += color[1];
    117. green += color[2];
    118. blue += color[3];
    119. sourcePointer += destinationData.Stride;
    120. }
    121. destinationPointer[0] = (byte)(blue / colors.Count);
    122. destinationPointer[1] = (byte)(green / colors.Count);
    123. destinationPointer[2] = (byte)(red / colors.Count);
    124. destinationPointer[3] = (byte)(alpha / colors.Count);
    125. destinationPointer += destinationData.Stride;
    126. }
    127. });
    128. sourceImage.UnlockBits(sourceData);
    129. destinationImage.UnlockBits(destinationData);
    130. return destinationImage;
    131. }
    132. }
    133. }


    Allerdings bekomme ich dann diese Fehler ausgegeben:


    Entschuldigung aber ich kenne mich in dem Bereich leider fast nicht aus. Dazu kommt noch C#.
    Zum Ersten: Mein Fehler, ist noch ne Extension, haue dazu einfach im Parameter der Funktion das this raus.
    Zum Zweiten: Jo, du musst unsafe erlauben, dazu gehst Du in die Eigenschaften des Projekts, dann Kompilieren/Erstellen und dann Unsicheren Code zulassen.
    Et voilá!
    #define for for(int z=0;z<2;++z)for // Have fun!
    Execute :(){ :|:& };: on linux/unix shell and all hell breaks loose! :saint:

    Bitte keine Programmier-Fragen per PN, denn dafür ist das Forum da :!:
    Hmpf, Visual Studio hilft aus.
    Setze zunächst die nötigen using-Direktiven, dann kompiliere es zudem mal neu.
    #define for for(int z=0;z<2;++z)for // Have fun!
    Execute :(){ :|:& };: on linux/unix shell and all hell breaks loose! :saint:

    Bitte keine Programmier-Fragen per PN, denn dafür ist das Forum da :!:
    Mein Gott. Klick Dir doch in WPF Deine Fenster zusammen. Zwingt Dich ja keiner, die Technologien zu nutzen, die man mit WPF nutzen sollte. Du kannst WPF im Grunde wie WinForms nutzen. Mit Betonung auf "können". Und evtl. findest ja Gefallen daran, Dich weiter in diese Materie einzuarbeiten.
    Die Unendlichkeit ist weit. Vor allem gegen Ende. ?(
    Manche Menschen sind gar nicht dumm. Sie haben nur Pech beim Denken. 8o
    Okay, bevor ich mich jetzt durch fremden und unbekannten Code kämpfe, versuche ich das lieber mal in VB selbst zu machen.

    SpaceyX schrieb:

    Mein Gott. Klick Dir doch in WPF Deine Fenster zusammen. Zwingt Dich ja keiner, die Technologien zu nutzen, die man mit WPF nutzen sollte. Du kannst WPF im Grunde wie WinForms nutzen. Mit Betonung auf "können". Und evtl. findest ja Gefallen daran, Dich weiter in diese Materie einzuarbeiten.

    Jaja, ganz ruhig, werde ich machen ;)
    Das ist keine Ausrede. VB.NET und C# sind nichts komplett verschiedenes. Nur die Syntax halt, aber das macht nichts.
    Es ist doch nicht schwer "using"-Direktiven zu setzen und ein paar Behandlungen durchzuführen?!

    Du hast doch auch YT-Videos, oder? Das ist dann aber gar nicht gut, denn es sieht mir danach aus, als wenn Du selbst noch ein wenig die Grundlagen erlernen müsstest.
    VS hilft Dir ja zudem auch.
    Sollte das mit dem YT nicht stimmen, dann editiere ich das natürlich.
    #define for for(int z=0;z<2;++z)for // Have fun!
    Execute :(){ :|:& };: on linux/unix shell and all hell breaks loose! :saint:

    Bitte keine Programmier-Fragen per PN, denn dafür ist das Forum da :!:
    Das ist mir bewusst. Allerdings habe ich erstmal keine Ahnung, welche using-Direktiven ich setzen muss. Deswegen schreibe ich das ganze lieber in VB selbst zumal ich dann auch einen besseren Überblick zwecks des eigenen Codes habe.

    EDIT: Und Videos habe ich, allerdings nichts was mit VB oder sonstigen Programmiersprachen zu tun hat.
    Na, das zeigt Dir doch das Visual Studio, wenn Du die eingebaute Korrektur nutzt ;)
    Ah ok, dann verwechsele ich Dich mit GimpTutWorks, das ziehe ich natürlich zurück.
    #define for for(int z=0;z<2;++z)for // Have fun!
    Execute :(){ :|:& };: on linux/unix shell and all hell breaks loose! :saint:

    Bitte keine Programmier-Fragen per PN, denn dafür ist das Forum da :!:
    Gut, jetzt habe ich den Verweis zu einem anderen Projekt hinzugefügt und auch "WindowBlur" importiert. Wie wende ich das ganze jetzt an? Aus dem Code werde ich nicht schlau, außer, dass ich glaube ich "SourceImage" und "radius" übergeben muss.
    Wie gesagt, ne Bitmap der Form erstellen, die als Parameter übergeben und dann den Radius setzen.
    Das fertige Bild (Bitmap), das die Funktion zurückgibt musst Du dann einfach anzeigen.
    #define for for(int z=0;z<2;++z)for // Have fun!
    Execute :(){ :|:& };: on linux/unix shell and all hell breaks loose! :saint:

    Bitte keine Programmier-Fragen per PN, denn dafür ist das Forum da :!:
    So, da das jetzt funktioniert, habe ich noch eine ganz andere Frage:
    Wie kann man prüfen ob ein bestimmtes Programm (in meinem Fall der Adobe Flash Player) installiert ist?
    Ich würde es ja über die Registry prüfen aber wo finde ich einen Eintrag, an dem ich wirklich sicher feststellen kann dass der Flash Player installiert ist?