2010-08-01 109 views
0

我想從網頁上從用戶上傳的圖像創建縮略圖。我想創建一個圖像庫,可以將所有圖像預覽顯示爲縮略圖,當用戶單擊時,他可以看到放大的圖像。如何從C#中的實際圖像創建縮略圖#

是否有可能做到這一點,使網頁不變得沉重

+0

我找到了一個C#圖像調整大小教程。我不知道C#。 http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing – msw 2010-08-01 08:23:14

回答

0

您必須爲圖像需要的類別標籤爲縮略圖。此這樣的:

.thumbnail { 
box-shadow: 0 0 7px #fff; 
cursor: pointer; 
float: left; 
height: 70px; 
margin-bottom: 10px; 
margin-top: -35px; 
width: 70px; 
border: 3px solid #ff``f; 
border-radius: 3px; 

}

等例如:

<img id="Image1" class="thumbnail" src="..." .../> 

和所有圖像的CSS調整大小。併爲創建放大的圖像,你必須使用jquery Modal。爲Modal閱讀此鏈接:http://www.jacklmoore.com/colorbox/ 您必須創建一個jquery文件。點擊每個圖片後,您必須使用您的src調用插件。這樣這個jquery:

$('.thumbnail').on('click', function() { 
var src = $(this).attr('src'); 
$(this).colorbox({ html: "<img src='" + src + "'      style='width:1024px;height:728px'/>", width: "1024px", height: "728px", close: "", closeButton: true, scrolling: false, overlayClose: true, scalePhotos: true, escKey: true }); 

});