|
using System;
using System.IO;
using System.Text;
using System.Collections;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Globalization;
//////////////////////////////////////////////////////////////////////////////
class FastBitmap : IDisposable, ICloneable
{
internal Bitmap _bitmap;
private BitmapData _bitmapData;
public FastBitmap(Int32 width, Int32 height, PixelFormat fmt)
{
_bitmap = new Bitmap(width, height, fmt);
}
public FastBitmap(String filename)
{
_bitmap = new Bitmap(filename);
}
~FastBitmap()
{
Dispose(false);
}
public void Dispose()
{
GC.SuppressFinalize(this);
Dispose(true);
}
protected virtual void Dispose(Boolean disposing)
{
Unlock();
if (disposing) {
_bitmap.Dispose();
}
}
private FastBitmap()
{
}
public Object Clone()
{
FastBitmap clone = new FastBitmap();
clone._bitmap = (Bitmap)_bitmap.Clone();
return clone;
}
public Int32 Width
{
get { return _bitmap.Width; }
}
public Int32 Height
{
get { return _bitmap.Height; }
}
public void Lock()
{
_bitmapData = _bitmap.LockBits(
new Rectangle(0, 0, _bitmap.Width, _bitmap.Height),
ImageLockMode.ReadWrite,
_bitmap.PixelFormat
);
}
unsafe public Color GetPixel(Int32 x, Int32 y)
{
if (_bitmapData.PixelFormat == PixelFormat.Format32bppArgb) {
Byte* b = (Byte*)_bitmapData.Scan0 + (y * _bitmapData.Stride) + (x * 4);
return Color.FromArgb(*(b + 3), *(b + 2), *(b + 1), *b);
}
if (_bitmapData.PixelFormat == PixelFormat.Format24bppRgb) {
Byte* b = (Byte*)_bitmapData.Scan0 + (y * _bitmapData.Stride) + (x * 3);
return Color.FromArgb(*(b + 2), *(b + 1), *b);
}
return Color.Empty;
}
unsafe public void SetPixel(Int32 x, Int32 y, Color c)
{
if (_bitmapData.PixelFormat == PixelFormat.Format32bppArgb) {
Byte* b = (Byte*)_bitmapData.Scan0 + (y * _bitmapData.Stride) + (x * 4);
*b = c.B;
*(b + 1) = c.G;
*(b + 2) = c.R;
*(b + 3) = c.A;
}
if (_bitmapData.PixelFormat == PixelFormat.Format24bppRgb) {
Byte* b = (Byte*)_bitmapData.Scan0 + (y * _bitmapData.Stride) + (x * 3);
*b = c.B;
*(b + 1) = c.G;
*(b + 2) = c.R;
}
}
please check it.. this is the error coming..
|
|
|
|
|
|
Hello Roy has posted a long time doubts about the use of filters in VisualStudio2005 Yael this site they were working all right but now using them as examples of source code-behind and below them are not recognized in VisualStudio2008,. NET Framework 3.5
I remember the folders where the images are uploaded due to my upload page to be in an administrative folder. They are a level above the upload page that is inside the folder management can see how the code below
I tried several times but without success with the filters back into service in VS2008
You have a solution for me or what I need to correct the code below to work out
I'm in waiting and I thank
SOURCE.ASPX
<pre><%@ Page Language="C#" AutoEventWireup="true" CodeFile="testeuploadnoticias.aspx.cs" Inherits="manager_testeuploadnoticias" ViewStateEncryptionMode="Always" EnableViewStateMac="true" ValidateRequest="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body><asp:Label ID="lblTitulo" runat="server"></asp:Label>
<form id="form1" runat="server">
<div>
<asp:Panel id="panResultado" runat="server" Visible="False">
<hr /> <table class="style1" align="center">
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Imagem Original da Noticia:" Visible="false"></asp:Label> <br />
<asp:image id="img1FotoNoticia" runat="server" Visible="false" /> <br /><br />Imagem Postada da Noticia: <br />
<asp:image id="img2FotoNoticia" runat="server" /><br /><br />
</td>
<td>
<td>
</td></td>
</tr>
</table><hr />
</asp:Panel>
Escolha a Foto da Notícia para enviar:<br />
<asp:FileUpload ID="arquivoFotoNoticia" runat="server" /><br />
<asp:Button ID="cmdEnviar" runat="server" Text="Enviar"
onclick="cmdEnviar_Click" />
<br />
<asp:Label ID="lblStatus" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
</pre>
CODE-BEHIND
<pre lang="c#">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProporcaoVB.WebProdutos.ProporcaoVB;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using ZRLabs.Yael.BasicFilters;
using ZRLabs.Yael.Common;
public partial class manager_testeuploadnoticias : System.Web.UI.Page
{
//Variaveis privadas e publicas para sistema de UPLOAD PROPORCIONAL
//MÓDULO DE NOTÍCIAS COM VARIAS RESOLUÇÕES
private string FolderOriginalNoticias;
private string FolderMiniaturaNoticias1024;
private string FolderGrandesNoticias1024;
private long Width1024 = 400;//EQUIVALENTE A RESOLUCAO WIDTH
private long Height1024 = 400;//EQUIVALENTE A RESOLUVAO HEIGHT
private long Widthpeq1024 = 220;
private long Heightpeq1024 = 220;
//static int maxsize;
public string Ext = "jpg";//TIPO DE EXTENSÃO ACEITA
//METODO DELFILE
static string deletado;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
// FolderOriginal = Server.MapPath("~/uploadmatriz/");
// FolderMiniatura = Server.MapPath("~/uploadtransformed/");
FolderOriginalNoticias = "..\\fotosnoticiasmatriz\\";//SEMPRE TERÁ QUE HAVER UMA FOLDER PARA AS FOTOS ORIGINAIS
FolderMiniaturaNoticias1024 = "..\\fotosnoticiasmatriz\\fotosnoticiaspeq1024\\";//FOLDERS MINIATURAS PODERÃO SER GRANDES E PEQUENAS COM AS DEVIDAS ADAPTERS
FolderGrandesNoticias1024 = "..\\fotosnoticiasmatriz\\fotosnoticiasgde1024\\";
//Cria Diretorio
//Directory.CreateDirectory((FolderOriginalNoticias));
//Directory.CreateDirectory((FolderMiniaturaNoticias1024));
//Directory.CreateDirectory((FolderGrandesNoticias1024));
}
}
protected void cmdEnviar_Click(object sender, EventArgs e)
{
//PAREI AQUI - AQUI INICIO DO METODO DE ENVIO DE UPLOAD
// FolderOriginal = Server.MapPath("~/uploadmatriz/");
// FolderMiniatura = Server.MapPath("~/uploadtransformed/");
FolderOriginalNoticias = "..\\fotosnoticiasmatriz\\";//SEMPRE TERÁ QUE HAVER UMA FOLDER PARA AS FOTOS ORIGINAIS
FolderMiniaturaNoticias1024 = "..\\fotosnoticiasmatriz\\fotosnoticiaspeq1024\\";//FOLDERS MINIATURAS PODERÃO SER GRANDES E PEQUENAS COM AS DEVIDAS ADAPTERS
FolderGrandesNoticias1024 = "..\\fotosnoticiasmatriz\\fotosnoticiasgde1024\\";
string NomeArquivoFotoNoticias;
//Faz Upload da Foto
//Pega o nome do Arquivo
NomeArquivoFotoNoticias = arquivoFotoNoticia.PostedFile.FileName.Substring(arquivoFotoNoticia.PostedFile.FileName.LastIndexOf("\\") + 1, arquivoFotoNoticia.PostedFile.FileName.Length - arquivoFotoNoticia.PostedFile.FileName.LastIndexOf("\\") - 1);
// maxsize = 4194304;
NomeArquivoFotoNoticias = NomeArquivoFotoNoticias.ToLower();
#region uploadnoticias
if (arquivoFotoNoticia.HasFile != false) // //Verifica se Arquivo foi Uploadado ou não Retornando True ou False
{
//Método para Recuperar Extensão do Arquivo
int totaldoarquivo;
string extensao;
totaldoarquivo = NomeArquivoFotoNoticias.Length;
totaldoarquivo = totaldoarquivo - 3;
// try
// {
extensao = NomeArquivoFotoNoticias.Remove(0, totaldoarquivo);
//Response.Write(extensao);
//SE ARQUIVO JÁ EXISTE RENOMEIA O ARQUIVO UPLOADADO
#region renomeiarquivosejaexistir
Random rnd = new Random();
string valor = string.Empty;
for (int i = 0; i < 12; i++)
{
if (rnd.Next(0, 2) == 1) // Caso seja 1, sorteia letras
{
valor += Convert.ToChar(rnd.Next(65, 91));
}
else
{
valor += Convert.ToChar(rnd.Next(48, 58));
}
}
valor = valor + DateTime.Now;
valor = valor.Replace(@"/", string.Empty);
valor = valor.Replace(":", string.Empty);
valor = valor.Replace(" ", string.Empty);
NomeArquivoFotoNoticias = NomeArquivoFotoNoticias.Replace("." + Ext, valor + "." + Ext);
#endregion
//try
//{
#region tamanhoarquivo
/// if (arquivoFotoNoticia.PostedFile.ContentLength < maxsize)//Método que verifica se Arquivo é maior que 4096 kbs(4mb)
/// {
//pronto para decisões
//baseado na variavel extensao para comparação
//com a string de entrada ext;
#region Extensao1
if (Ext != null || Ext != string.Empty || Ext != "" || Ext != " ")
{
if (Ext == extensao)
{
try
{
//Aqui criar o nome do arquivo file com algum tipo de replace
//para gerar nomearquivodatahoraournd.ext
//algo parecido com isto
//file = file.Replace("." + ext, Convert.ToString(width) + Convert.ToString(height) + "." + ext);
//ou usar file = nomeupload
arquivoFotoNoticia.PostedFile.SaveAs(Server.MapPath("../fotosnoticiasmatriz/") + NomeArquivoFotoNoticias); //Grava o nome original do Arquivo
}
catch
{
}
//PAREI AQUI EM 20/10/2011
//Verifica E RECUPERA O TAMANHO DA FOTO UPLOADADA
#region verificafotopedeitada
// Cria temporariamnte a imagem
System.Drawing.Image imagemTemp = System.Drawing.Image.FromFile(Server.MapPath("../fotosnoticiasmatriz/") + NomeArquivoFotoNoticias);
// Variáveis contendo o tamanho
int srcWidth = imagemTemp.Width;
int srcHeight = imagemTemp.Height;
Response.Write("Largura:" + srcWidth + "Altura:" + srcHeight);
#endregion
#region decisaofotopedeitada
if (srcWidth > srcHeight)
{
//Inicio Metodo de Filtros
//Filtro AddIn ProporcaoVB
//Gera a miniatura da noticia
//para a resolucao 1024x768 peq
ProporcaoUpload proporcaopeq1024 = new ProporcaoUpload();
proporcaopeq1024.GerarMiniatura(NomeArquivoFotoNoticias, FolderOriginalNoticias, FolderMiniaturaNoticias1024, Widthpeq1024, Heightpeq1024, panResultado, img1FotoNoticia, img2FotoNoticia, lblTitulo, lblStatus);
//AQUI PARA CADA RESOLUÇÃO, CRIAR ROTINA FILTROS OU METODO YAEL Á SEREM USADOS
//Inicio do uso do Filtro
System.Drawing.Image transformed1024;
//Captura o Caminho+Arquivo Carregado
System.Drawing.Image myImg1024 = System.Drawing.Image.FromFile(Server.MapPath("../fotosnoticiasmatriz/fotosnoticiaspeq1024/"+NomeArquivoFotoNoticias+"") );
System.Drawing.Image myImg1024 =
//Utiliza o Filtro Rounded para as fotos pequenas
RoundedCorners rounded = new RoundedCorners();
rounded.BackGroundColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
rounded.CornerRadius = 35;
transformed1024 = rounded.ExecuteFilter(myImg1024);
//para a resolucao 1024x768 gde
ProporcaoUpload proporcaogde1024 = new ProporcaoUpload();
FolderGrandesNoticias1024.Replace(@"//", "/");
proporcaogde1024.GerarMiniatura(NomeArquivoFotoNoticias, FolderOriginalNoticias, FolderGrandesNoticias1024, Width1024, Height1024, panResultado, img1FotoNoticia, img2FotoNoticia, lblTitulo, lblStatus);
//AO FINAL AQUI GRAVAR DADOS BASE DE DADOS
Response.Write(NomeArquivoFotoNoticias);
}
else
{
//lblStatus.Text = "Por favor faça upload apenas de fótos [DEITADAS].Para não enxer sua pasta de fotos.Clique no Botão [DELETAR] para deletar o arquivo " + NomeArquivoFotoNoticias;
HttpContext.Current.Response.Write(@"<script language='javascript'>alert( 'Por favor faça upload apenas de fótos [DEITADAS]!!!' );</script>");
//COLOCAR AQUI MYSQL BD TABLE PARA INSERÇÃO DA FOTO DO ARQUIVOMATRIZ
//E NO INICIO DA PASTA ADMIN OU DESTA CRIAR UM ORDER BY DESC
//PEGANDO O ULTIMO ARQUIVO INSERIDO PARA DELEÇÃO E DELETANDO-O AUTOMATICAMENTE
//COM ROTINA TRY CATCH PARA EVITAR ERRO CASO NÃO HAJA MAIS REGISTROS NO BD
//MÉTODO DE DESTRUIÇÃO DA FOTO ARQUIVO NA PASTA
//DelFile(NomeArquivoFotoNoticias, "../fotosnoticiasmatriz/", lblStatus);
}
#endregion
}
}
#endregion
/// }
#endregion
}
#endregion
}
</pre>
LADEF
|
|
|
|
|
Hello I'm using the following code below that already use Visual Studio2005 and he added the System.Drawing.Image requires to function properly
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using ZRLabs.Yael.BasicFilters;
using ZRLabs.Yael.Common;
namespace UploadCS
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int width = 50;
int height = 50;
System.Drawing.Image transformed;
System.Drawing.Image myImg = System.Drawing.Image.FromFile("e:/home/meudiretorio/www/mywebapp/upload/bimundialuggt6.png ");
ResizeFilter resize = new ResizeFilter();
resize.Width = width;
resize.Height = height;
transformed = resize.ExecuteFilter(myImg);
transformed.Save("e:/home/meudiretorio/www/mywebapp/upload/bimundialuggt6.png ");
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
}
in localhost it works perfectly only when the public on my web server it gives error of GDI + as I could solve it. If you can help me now thank you
LADEF
|
|
|
|
|
Hello I am creating a Asp.Net Ajax Enabled WebApplication Project that I am only trying to use the object with FileUpload Using the FileUpload Control with AC # image enhancement filters library but I am not getting transform based on their examples. You have some in Csharp example of how to use your filter to the object has already FileUpload thank
LADEF
|
|
|
|
|
Hey there! Great library, very handy! I have a problem, however, with the dropshadow! I've taken an image, resized it to a thumbnail, then tried to apply a drop-shadow, and it sorta works - but in the top-right and lower-left corners of the new image, there are these black spots.
I'm running this on Vista x64 with .NET 3.5 SP1...
Here's the code:
Dim myImg As Image
myImg = Image.FromFile("c:/t/1.jpg")
Dim transformedImage As Image
Dim rf As ResizeFilter = New ResizeFilter
rf.Width = 72
rf.Height = 64
rf.BackGroundColor = Color.White
transformedImage = rf.ExecuteFilter(myImg)
Dim dr As DropShadowFilter = New DropShadowFilter
transformedImage = dr.ExecuteFilter(transformedImage)
Any idea what might be causing this?
---
Industrial Strength Flight Tracking
|
|
|
|
|
Hi,
This is probably because you are saving your images in jpeg and transparency is not supported (these two black spots pixels you mentioning should be transparent). Try saving the transformed image as png of gif
Let me know how it went for you.
|
|
|
|
|
I would like to know how I could use the filter to textWaterMark that my textCaption is like them in the right or left side of the picture
w
w
w
.
m
y
d
o
m
i
n
i
.
c
o
m
Translated from Portuguese to English by Google
LADEF
|
|
|
|
|
Hi LuizItatiba,
This functionality is currently not supported.
I'll try to add this functionality to the new version.
Do you have any examples where you might use it ?
|
|
|
|
|
Here it would be very well used, you only give you a hint on which images have a resolution in ex-foot width = 225 height = 300, has people like some sites would like to put the www or another word instead of more extensive www.dominio . with
w
w
w
.
d
the
m
i
n
i
the
.
c
the
m
is on the right or left of the image,
you see an example of how this could be used see the pictures of this site, http://www.carolinebastos.com/. recalling that this site was not done by me just to give you an example of how this can be well used was added to the component
if you can help me get in and look forward now appreciate
Translated from Portuguese to English by Google
LADEF
|
|
|
|
|
I'm happy to tell that a small set of the filters in this project are available online at www.imgtoys.com[^]
Currently the available filters are Text Watermark, Floor Reflection and an added bonus, EXIF metadata editor.
Check it out at http://www.imgtoys.com
|
|
|
|
|
Working with the filter
Text Captions and WaterMarks
Let's say I want to use a water mark with 2 lines
as if
textWaterMark.Caption = "Pitzi";
and on the bottom line
textWaterMark.Caption = "© 2008";
where the result would be etched on the image
Pitzi
© 2008
As in the code of the filter I change or which character linefeed I put it in the text to skip a line
Regards - Luiz - Brazil
Translated - Portuguese to English by Google
LADEF
|
|
|
|
|
For Dlls or components used in reference to the application they are to use Free or has Validity of Cessation?
Regards - Luiz - Brazil
Portuguese Translated into English by Google
LADEF
|
|
|
|
|
I was working as shown in the routine code below with the filter Rounded Corners Filter
RoundedCorners rounded = new RoundedCorners();
rounded.BackGroundColor = Color.FromArgb(255,52,1,31);
//rounded.BackGroundColor = Color.Aqua;
rounded.CornerRadius = 35;
transformed = rounded.ExecuteFilter(transformed);
and would like to know what the minimum and maximum limits of alpha that can sêr used the data of the line
rounded.BackGroundColor = Color.FromArgb(255,52,1,31);
The reason for this is that my background color in hexadecimal is "# 34011F", if there is a means or method in the line that he recognizes the color in hexadecimal would also be used for the same line
rounded.BackGroundColor = Color.FromArgb(255,52,1,31);
instead of Color.FromArgb
Regards Luiz - Brazil
Translated from Portuguese into English by Google
LADEF
|
|
|
|
|
Dude, I'm sorry , I really tried to understand what you are asking here but it seems that google is not doing such a good job of translating your question. Can you maybe ask someone to help rephrasing the question better ?
Thanks
Roiy
|
|
|
|
|
What I meant to say is on the line
rounded.BackGroundColor = Color.FromArgb (255,52,1,31);
The limit of alpha used is between 0 (more transparent) to 255 (less transparent) or has more than 255 in less transparent
LADEF
|
|
|
|
|
|
Ah ok éra what I wanted to know this issue very much
Regards - Luiz
LADEF
|
|
|
|
|
Working with Drop Shadow filter in dark pages with funds
in images that have in their background colors as escurar
# 34011F, as to make the text on the page with that background color appears a white square around the image
Image transformed;
DropShadowFilter dropShadow = new DropShadowFilter();
transformed = dropShadow.ExecuteFilter(myImg);
Regards Luiz - Brazil
Translated from Portuguese into English by Google
LADEF
|
|
|
|
|
Hello Roy of your code example below
using System.Drawing;
using System.IO;
using ZRLabs.Yael.BasicFilters;
using ZRLabs.Yael.Common.Interfaces;
...
...
Image transformed;
Image myImage = Image.FromFile("c:/input.jpg");
ResizeFilter resize = new ResizeFilter();
resize.Width = 100;
resize.Height = 70;
transformed = resize.ExecuteFilter(myImg);
transformed.Save("c:/output.jpg");
Two questions
1) Insert example of the code in code-behind the VS2005 and added the references above, I am using the ace References v1.0.3.0 (LGPL)
He asks only one name space on the lines
Image transformed;
Image myImage = Image.FromFile("c:/input.jpg");
For the object image, I know what name space that would be?
2) In place of Save the image converted just wanted exibíla for viewing within an object image such as the code below the line
Image1.ImageUrl = ("http://output.jpg"); for example
For this to happen I would have to do instead of using the option
transformed.Save("c:/output.jpg");
which method I would have to put in place do. Save for display only the image of the object within Image1
Thanks and I look forward
Luiz - Brazil
Translated from Portuguese into English by Google
LADEF
|
|
|
|
|
1)You'll have to add System.Drawing.Image (not just for the using line but also for your project references )
2)Didn't understand your question
|
|
|
|
|
What I want to say is that in your project is an example of saving an image in the format because the filter, but I wonder if before saving it for example in any code appeal to show it and link it to a object image as below
Image1.ImageUrl = ( "http://output.jpg") eg
LADEF
|
|
|
|
|
Hello seeing your link seen several examples of examples in ViewCode as below
Image transformed;
RoundedCorners rounded = new RoundedCorners();
rounded.BackGroundColor = Color.FromArgb(255, 255, 255, 255);
rounded.CornerRadius = 30;
transformed = rounded.ExecuteFilter(myImg);
I wanted to know what is taking up these examples where would I put for instance the name of my file of entrada.jpg in that code and picked up where the same file already filtered to switch to a variable in CSHARP, but also where part or event of my page put the mesmo.Estou using VS2005 Pro Edition eng-use
Thanks if you can help me now thank you
This text was translated by Google
LADEF
|
|
|
|
|
Not sure I understand your question.
If you want to load up the original image to the myImg variable, then this is the way to do it
Image myImg = Bitmap.FromFile("cat.jpg");
You can also use the example code in the example solution. You can download the latest version from
[here]
Hope this helps you
Roiy
|
|
|
|
|
That's right thank you and taking advantage Roiy, the examples in your page may sêr used freely in any website that I develop, or lose its operation after 30 days or any time and if I can pass it as an example not to save the image by uploading I believe that this is already in his example I saw the page, but only to see the image or repassá it to a variable such as this would be
Regards - Luiz - Brazil
Translated from Portuguese to English by Google
LADEF
|
|
|
|
|