Default.aspx
// Resim Servis | www.aliakyildirim.com | Ali AKYILDIRIM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
// Resim Servis | www.aliakyildirim.com | Ali AKYILDIRIM
namespace ConsumeForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Vekil.pictureclassssss pc = new ConsumeForm.Vekil.pictureclassssss();
private void button1_Click(object sender, EventArgs e)
{
byte[] resim = pc.CreatePicture(textBox1.Text,checkBox1.Checked);
MemoryStream mem = new MemoryStream(resim);
Image img = Image.FromStream(mem);
pictureBox1.Image = img;
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Focus();
}
}
}
// Resim Servis | www.aliakyildirim.com | Ali AKYILDIRIM
Web Servis
pictureserviceeeeeeee.asmx
// Resim Servis | www.aliakyildirim.com | Ali AKYILDIRIM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
// Resim Servis | www.aliakyildirim.com | Ali AKYILDIRIM
namespace pictureserviceeeeeeee
{
///
/// Summary description for pictureclassssss
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class pictureclassssss : System.Web.Services.WebService
{
[WebMethod]
public byte[] CreatePicture(string keyword, bool isdraw)
// 2. parametre eger checkbox isaretliyse olusturulan resmin üstünü çizsin diye verilen boolean degiskeni.
{
Bitmap bmp = new Bitmap(100, 30);
Graphics g = Graphics.FromImage(bmp);
g.Clear(Color.White);
Font f = new Font("Verdana", 12, FontStyle.Bold);
Rectangle r = new Rectangle(0, 0, 100, 30);
StringFormat yazihizalama = new StringFormat();
//stringFormat yatay dikey hizalama yapar.
yazihizalama.Alignment = StringAlignment.Center;
yazihizalama.LineAlignment = StringAlignment.Center;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
//stringler için,grafik olarak yazdirdiginizda dönüslerdeki kiriklari etkiler daha yumusak geçis yapmasini saglar.
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
//stringleri degil nesne çizerken geçislerin daha yumusak olmasini saglar
g.DrawString(keyword, f, Brushes.Red, r, yazihizalama);
if (isdraw)
g.DrawLine(Pens.Black, 0, 0, 100, 30);
MemoryStream mem = new MemoryStream();
bmp.Save(mem, ImageFormat.Png);
f.Dispose();
g.Dispose();
bmp.Dispose();
return mem.ToArray();
//memorystream içindeki datayi bytes ( byte dizisi) olarak geri döndürür.
}
}
}
// Resim Servis | www.aliakyildirim.com | Ali AKYILDIRIM