vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
TOP-Angebot: 17 bzw. 24 Entwickler-Vollversionen zum unschlagbaren Preis!  
 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

VB.NET - Fortgeschrittene
Re: Spiegel Bild einer PictureBox von C# ins VB 
Autor: henrikl2000
Datum: 04.05.15 11:37

Der C# Code
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
 
	public class ReflectedThumbnail : IDisposable
	{
		public Bitmap ThumbnailImage;
		public int ImageBottom;
 
		public Size MaxSize;
		public int Skew;
		public int FrameWidth;
		public int MaxReflectionLength;
 
		public Pen BorderPen = Pens.Gray;
		public Brush FrameBrush = Brushes.White;
 
		private struct Pixel
		{
			public byte B;
			public byte G;
			public byte R;
			public byte A;
		}
 
		public ReflectedThumbnail() : this(
			new Size( 128, 128 ),
			20,
			3,
			80 )
		{
		}
 
		public ReflectedThumbnail(
			Size maxSize,
			int skew,
			int frameWidth,
			int maxReflectionLength )
		{
			MaxSize = maxSize;
			Skew = skew;
			FrameWidth = frameWidth;
			MaxReflectionLength = maxReflectionLength;
		}
 
		public void Dispose()
		{
			DisposeBitmap();
		}
 
		public void DisposeBitmap()
		{
			if ( ThumbnailImage != null )
			{
				ThumbnailImage.Dispose();
				ThumbnailImage = null;
			}
		}
 
		public void create(
			Bitmap image )
		{
			DisposeBitmap();
 
			Size sz = adaptProportionalSize(
				new Size( MaxSize.Width - FrameWidth * 2, MaxSize.Height - FrameWidth * 2 ),
				image.Size );
			sz.Width += FrameWidth * 2;
			sz.Height += FrameWidth * 2;
 
			ImageBottom = sz.Height;
 
			int reflectionLength = Math.Min( sz.Height, MaxReflectionLength );
			ThumbnailImage = new Bitmap(
				sz.Width,
				sz.Height + reflectionLength + Skew );
 
			using ( Bitmap
				bmpFramed = createFramedBitmap( image, sz ),
				bmpReflection = createReflectedBitmap( bmpFramed, reflectionLength ) )
			using ( Graphics g = Graphics.FromImage( ThumbnailImage ) )
			{
				// draw the reflected image to the resulting image
				// using a shear transform
				System.Drawing.Drawing2D.Matrix m = g.Transform;
				m.Shear( 0, (float)Skew / sz.Width );
				m.Translate( 0, sz.Height - Skew - 1 );
				g.Transform = m;
				g.DrawImage( bmpReflection, Point.Empty );
				g.ResetTransform();
 
				// draw the real (framed) image to the resulting image
				// one column at a time, slightly altering the height
				// of the destination column in order to create the
				// "half sheared" transform
				for ( int x = 0 ; x < sz.Width ; x++ )
					g.DrawImage(
						bmpFramed,
						new RectangleF( x, 0, 1, sz.Height - Skew * (float)(sz.Width - x) / _
  sz.Width ),
						new RectangleF( x, 0, 1, sz.Height ),
						GraphicsUnit.Pixel );
			}
 
		}
 
		protected virtual Bitmap createFramedBitmap( Bitmap bmpSource, Size szFull )
		{
			Bitmap bmp = new Bitmap( szFull.Width, szFull.Height );
			using ( Graphics g = Graphics.FromImage( bmp ) )
			{
				g.FillRectangle( FrameBrush, 0, 0, szFull.Width, szFull.Height );
				g.DrawRectangle( BorderPen, 0, 0, szFull.Width - 1, szFull.Height - 1 );
				g.InterpolationMode = _
  System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
				g.DrawImage(
					bmpSource,
					new Rectangle( FrameWidth, FrameWidth, szFull.Width - FrameWidth * 2, _
  szFull.Height - FrameWidth * 2 ),
					new Rectangle( Point.Empty, bmpSource.Size ),
					GraphicsUnit.Pixel );
			}
			return bmp;
		}
 
		private static unsafe byte gaussBlur( byte* p, int width )
		{
			unchecked
			{
				return (byte)(( p[-width - 4] + 2 * p[-width] + p[-width + 4] +
									2 * p[-4] + 4 * p[0] + 2 * p[4] +
									p[width - 4] + 2 * p[width] + p[width + 4] ) / 16);
			}
		}
0
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Spiegel Bild einer PictureBox von C# ins VB1.454henrikl200004.05.15 11:35
Re: Spiegel Bild einer PictureBox von C# ins VB811henrikl200004.05.15 11:37
Re: Spiegel Bild einer PictureBox von C# ins VB763henrikl200004.05.15 11:37
Re: Spiegel Bild einer PictureBox von C# ins VB793Manfred X04.05.15 12:00
Re: Spiegel Bild einer PictureBox von C# ins VB895Manfred X04.05.15 13:34
Re: Spiegel Bild einer PictureBox von C# ins VB911henrikl200004.05.15 14:57
Re: Spiegel Bild einer PictureBox von C# ins VB785Manfred X04.05.15 15:32
Re: Spiegel Bild einer PictureBox von C# ins VB776henrikl200004.05.15 22:31
Re: Spiegel Bild einer PictureBox von C# ins VB816sv0001005.05.15 05:31
Re: Spiegel Bild einer PictureBox von C# ins VB697henrikl200005.05.15 08:10

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