Skip to content

Commit

Permalink
Fix bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Aug 30, 2013
1 parent da8d9b0 commit 0dcf568
Show file tree
Hide file tree
Showing 17 changed files with 711 additions and 618 deletions.
17 changes: 7 additions & 10 deletions src/AtomLab.Utility/ImageProcessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,19 +264,19 @@ public static void CutForSquare(System.IO.Stream fromFile, string fileSaveUrl, i
/// </summary>
/// <remarks>吴剑 2010-11-15</remarks>
/// <param name="postedFile">原图HttpPostedFile对象</param>
/// <param name="fileSaveUrl">保存路径</param>
/// <param name="file">保存路径</param>
/// <param name="maxWidth">最大宽(单位:px)</param>
/// <param name="maxHeight">最大高(单位:px)</param>
/// <param name="quality">质量(范围0-100)</param>
public static void CutForCustom(System.Web.HttpPostedFile postedFile, string fileSaveUrl, int maxWidth, int maxHeight, int quality)
public static void CutForCustom(string file, int maxWidth, int maxHeight, int quality)
{
//从文件获取原始图片,并使用流中嵌入的颜色管理信息
System.Drawing.Image initImage = System.Drawing.Image.FromStream(postedFile.InputStream, true);
System.Drawing.Image initImage = System.Drawing.Image.FromFile(file, true);

//原图宽高均小于模版,不作处理,直接保存
if (initImage.Width <= maxWidth && initImage.Height <= maxHeight)
{
initImage.Save(fileSaveUrl, System.Drawing.Imaging.ImageFormat.Jpeg);
initImage.Save(file, System.Drawing.Imaging.ImageFormat.Jpeg);
}
else
{
Expand All @@ -295,7 +295,7 @@ public static void CutForCustom(System.Web.HttpPostedFile postedFile, string fil
templateG.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
templateG.Clear(Color.White);
templateG.DrawImage(initImage, new System.Drawing.Rectangle(0, 0, maxWidth, maxHeight), new System.Drawing.Rectangle(0, 0, initImage.Width, initImage.Height), System.Drawing.GraphicsUnit.Pixel);
templateImage.Save(fileSaveUrl, System.Drawing.Imaging.ImageFormat.Jpeg);
templateImage.Save(file, System.Drawing.Imaging.ImageFormat.Jpeg);
}
//原图与模版比例不等,裁剪后缩放
else
Expand Down Expand Up @@ -374,13 +374,10 @@ public static void CutForCustom(System.Web.HttpPostedFile postedFile, string fil
ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (long)quality);

//保存缩略图
templateImage.Save(fileSaveUrl, ici, ep);
//templateImage.Save(fileSaveUrl, System.Drawing.Imaging.ImageFormat.Jpeg);

//释放资源
initImage.Dispose();
templateImage.Save(file, ici, ep);
templateG.Dispose();
templateImage.Dispose();

pickedG.Dispose();
pickedImage.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@

$scope.entity= {}

#TODO 如果Global中用户信息读取比此处慢,将无法绑定用户信息到界面.
$scope.entity.Author = $scope.User.UserName
$scope.entity.Email = $scope.User.Email
$scope.entity.Url = $scope.User.Url
$scope.AuthorForDisplay=$scope.User.UserName
$scope.editmode=$scope.User.UserName=='' or not $scope.User.UserName?
$scope.$watch 'User',->
if $scope.User
$scope.entity.Author = $scope.User.UserName
$scope.entity.Email = $scope.User.Email
$scope.entity.Url = $scope.User.Url
$scope.AuthorForDisplay=$scope.User.UserName
$scope.editmode=$scope.User.UserName=='' or not $scope.User.UserName?

$scope.del = (item) ->
Comment.del {id:item.CommentId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,15 @@ ArticleDetailController = [
});
});
$scope.entity = {};
$scope.entity.Author = $scope.User.UserName;
$scope.entity.Email = $scope.User.Email;
$scope.entity.Url = $scope.User.Url;
$scope.AuthorForDisplay = $scope.User.UserName;
$scope.editmode = $scope.User.UserName === '' || !($scope.User.UserName != null);
$scope.$watch('User', function() {
if ($scope.User) {
$scope.entity.Author = $scope.User.UserName;
$scope.entity.Email = $scope.User.Email;
$scope.entity.Url = $scope.User.Url;
$scope.AuthorForDisplay = $scope.User.UserName;
return $scope.editmode = $scope.User.UserName === '' || !($scope.User.UserName != null);
}
});
$scope.del = function(item) {
return Comment.del({
id: item.CommentId
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
$scope.loading=true
$scope.entity= {}

$scope.entity.Author = $scope.User.UserName
$scope.entity.Email = $scope.User.Email
$scope.entity.Url = $scope.User.Url
$scope.AuthorForDisplay=$scope.User.UserName
$scope.editmode=$scope.User.UserName=='' or not $scope.User.UserName?
$scope.$watch 'User',->
if $scope.User
$scope.entity.Author = $scope.User.UserName
$scope.entity.Email = $scope.User.Email
$scope.entity.Url = $scope.User.Url
$scope.AuthorForDisplay=$scope.User.UserName
$scope.editmode=$scope.User.UserName=='' or not $scope.User.UserName?

$scope.list = Message.query $filter:'IsDeleted eq false',->
for item in $scope.list.value
if item.Email
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ MessageController = [
$scope.$parent.showBanner = false;
$scope.loading = true;
$scope.entity = {};
$scope.entity.Author = $scope.User.UserName;
$scope.entity.Email = $scope.User.Email;
$scope.entity.Url = $scope.User.Url;
$scope.AuthorForDisplay = $scope.User.UserName;
$scope.editmode = $scope.User.UserName === '' || !($scope.User.UserName != null);
$scope.$watch('User', function() {
if ($scope.User) {
$scope.entity.Author = $scope.User.UserName;
$scope.entity.Email = $scope.User.Email;
$scope.entity.Url = $scope.User.Url;
$scope.AuthorForDisplay = $scope.User.UserName;
return $scope.editmode = $scope.User.UserName === '' || !($scope.User.UserName != null);
}
});
$scope.list = Message.query({
$filter: 'IsDeleted eq false'
}, function() {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Http.OData;
using System.Web.Http.OData.Query;
using AtomLab.Utility;
using Gma.QrCodeNet.Encoding;
using Gma.QrCodeNet.Encoding.Windows.Render;
using YangKai.BlogEngine.Common;
using YangKai.BlogEngine.Domain;
using YangKai.BlogEngine.Service;
using YangKai.BlogEngine.Web.Mvc.Areas.Admin.Common;
using QrCode = YangKai.BlogEngine.Domain.QrCode;

namespace YangKai.BlogEngine.Web.Mvc.Controllers.OData
{
Expand Down Expand Up @@ -73,10 +81,28 @@ private Post AddArticle(Post entity, bool isNew = true)
File.Delete(target);
}
File.Move(source, target);
ImageProcessing.CutForCustom(target, 160, 100, 100);
entity.Thumbnail.Url = filename;
}
}

//添加Post.Qrcode
entity.QrCode = new QrCode
{
Content = entity.Title,
Url = entity.Url + ".png"
};
var gRender = new GraphicsRenderer(new FixedModuleSize(30, QuietZoneModules.Four));
var fullUrl = Config.URL.Domain + "/#!/post/" + entity.Url;
BitMatrix matrix = new QrEncoder().Encode(entity.QrCode.Content + " | " + fullUrl).Matrix;
using (var stream = new FileStream(HttpContext.Current.Server.MapPath("/upload/qrcode/" + entity.QrCode.Url), FileMode.Create))
{
gRender.WriteToStream(matrix, ImageFormat.Png, stream, new Point(1000, 1000));
}

entity.Content = SaveRemoteFile.SaveContentPic(entity.Content, entity.Url);
entity.Description = SaveRemoteFile.SaveContentPic(entity.Description, entity.Url);

entity = Proxy.Repository<Post>().Add(entity);
Rss.BuildPostRss();
return entity;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0dcf568

Please sign in to comment.