Wednesday, February 17, 2010

Duofem And Ferrous Fumsrate Tablets

Example ASP.NET. GetThumbnailImage thumbnails

The method of the Bitmap class has a very simple function, create an image the size you want based on the image to retire existing.

This example uses a technique somewhat basic, and running through a folder of images and creates in a temporary folder then displays the thumbnails. An evolution of this example is to create us a gallery with thumbnails without having to store them on the hard

Regarding the submission of the dump thumbnails directly to the page, without any control container, only to simplify the code

More information about this method in http://msdn.microsoft.com/es-es/library/system.drawing.image.getthumbnailimage.aspx Instructions


  1. In a asp.net website to add a new page (web form) with the name GaleriaImagenes
  2. Create a folder named "images" and within this folder, create another with the name "tmp"
  3. Put some pictures in jpg format in the folder "images"
  4. Copy this code by replacing the existing file
  5. Run GaleriaImagenes.aspx.vb
page
Source Imports System.IO 'namespace with classes to go

folders Imports System.Drawing' space names with classes related to the images

Partial Class Inherits System.Web.UI.Page GaleriaImagenes


'walk along the folder creating a thumbnail image for each image
CargarGaleria Protected Function () As Boolean

'I think an object associated with the folder you want to go
DINF Dim As New IO.DirectoryInfo (Server.MapPath ("images"))

' create an object associated with the procedure (addressOff) we are using If you have to cancel the execution of the method of image GetThumnail
MyCallback Dim As New Image.GetThumbnailImageAbort Image.GetThumbnailImageAbort = (AddressOf CargarGaleria)

'for CDAD picture in the folder and be of type bmp jpg create an object
' and then use the method to create the thumbnail getThumnailImage
IO.FileInfo For Each ace In DINF im. GetFiles ("*. jpg")
Dim bmp As New Bitmap (im.FullName)
nuevoBmp Dim As Bitmap = bmp.GetThumbnailImage (bmp.Width / 4, bmp.Height / 4, MyCallback, IntPtr.Zero)

'Save the thumbnail in the temporary folder and create a control associated with the thumbnail image
nuevoBmp.Save (MapPath ("/ images / tmp /" & im.Name) Imaging.ImageFormat.Jpeg)
; Dim As New UI.WebControls.HyperLink
mini mini.ImageUrl = "~ / Images / tmp /" & im.Name
mini.NavigateUrl = "~ / images /" & im.Name
'once created the control I add to the gallery page cotrol
Me.Controls.Add (mini)

   'elimino los controles
          mini.Dispose()
          nuevoBmp.Dispose()
Next

End Function

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
         CargarGaleria()
End Sub
End Class

0 comments:

Post a Comment