There is apparently no easy way to generate a transparent GIF image using the .NET framework. Microsoft provided a method in the Bitmap class called MakeTransparent() but it doesn’t work for GIFs, it only seems to work for PNGs.
To create a transparent GIF you need to recreate the color table of the image using Imaging APIs. Unfortunately, this can be pretty slow for an ASP.NET Web application, and it has a lot of overhead, so I needed an alternative.
Solution:
The alternative is to alter the color table directly using the GIF specification. To implement this, I needed to save the non-transparent GIF to a MemoryStream, and then go through the binary data, updating the color table with the new transparency bits.
Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts
Monday, December 7, 2009
Wednesday, October 28, 2009
How to increase sound level using C#
To increase sound level using C# first of all you should add line:
to allow using COM Interop in your class.
Next we derlare two functions from an unmanaged DLL:
using System.Runtime.InteropServices;
to allow using COM Interop in your class.
Next we derlare two functions from an unmanaged DLL:
Ярлыки:
.NET,
C#,
COM Interop,
Sound,
waveOutGetVolume,
waveOutSetVolume,
winmm.dll
Friday, October 23, 2009
Capture Sound and save into wav or mp3 file .NET C# example
It's surprising that there are no components for sound capturing in .NET Framework 3.5. Even designers of WPF and Silverlight 2.0 were focused on graphics so deeply, that they forgot about applications recording sound from user's microphone. It is said that the next version of Silverlight will provide such functionality.
However, what you often want to achieve is to store the recorded sound in MP3 file (or send it as MP3 stream). That's legally complicated due to MP3 patent constraints. And for the same legal reason, we can assume that we will not see MP3 functionality in Microsoft technologies soon (there is WMA instead).
However, what you often want to achieve is to store the recorded sound in MP3 file (or send it as MP3 stream). That's legally complicated due to MP3 patent constraints. And for the same legal reason, we can assume that we will not see MP3 functionality in Microsoft technologies soon (there is WMA instead).
Wednesday, July 29, 2009
How to get data from Firebird database using MS SQL Server stored procedure
In solving one of the tasks (рассчет автокредита) I needed an opportunity to perform stored procedure of SQL Server 2005, to receive data from the FireBird database.
Typically stored procedure in T-SQL can not do this, so I wrote a stored procedure in C#, which receives the necessary data to the DataTable(s), from where then method SqlContext.Pipe.SendResultsRow, passing a string SQL Server.
Here is the example:
Typically stored procedure in T-SQL can not do this, so I wrote a stored procedure in C#, which receives the necessary data to the DataTable(s), from where then method SqlContext.Pipe.SendResultsRow, passing a string SQL Server.
Here is the example:
Ярлыки:
C#,
CLR,
DataTable,
Firebird,
SendResultsRow,
SQL Server,
stored procedure,
t-sql
Wednesday, March 25, 2009
How to disable passing of HTTP header "Expect: 100-continue" using HttpWebRequest in .NET Framework in C#?
How to disable passing of HTTP header "Expect: 100-continue" using HttpWebRequest in .NET Framework in C#?
По умолчанию, при выполнении веб-запроса, используя класс HttpWebRequest, .NET Framework добавляет HTTP заголовок (HTTP header) "Expect: 100-continue". Для того, чтобы запретить формирование этого заголовка нужно сделать следующее:
As default when You use HttpWebRequest class to execute web-requests it appends HTTP header "Expect: 100-continue" to it's headers collection. To disable passing of HTTP header "Expect: 100-continue" using HttpWebRequest You can do following:
По умолчанию, при выполнении веб-запроса, используя класс HttpWebRequest, .NET Framework добавляет HTTP заголовок (HTTP header) "Expect: 100-continue". Для того, чтобы запретить формирование этого заголовка нужно сделать следующее:
As default when You use HttpWebRequest class to execute web-requests it appends HTTP header "Expect: 100-continue" to it's headers collection. To disable passing of HTTP header "Expect: 100-continue" using HttpWebRequest You can do following:
Ярлыки:
.NET,
C#,
Expect: 100-continue,
header,
HTTP,
HttpWebRequest
How to place DateTimePicker onto ToolStrip control in Windows Forms .NET application?
To place DateTimePicker onto ToolStrip control in Windows Forms .NET application you had to do following:
DateTimePicker dateTimePcr = new DateTimePicker();
toolStrip1.Items.Add(new ToolStripControlHost(dateTimePcr));
DateTimePicker dateTimePcr = new DateTimePicker();
toolStrip1.Items.Add(new ToolStripControlHost(dateTimePcr));
Ярлыки:
.NET,
C#,
DateTimePicker,
Forms,
ToolStrip,
ToolStripControlHost,
Windows
Thursday, February 5, 2009
How to change in code the title of web page in Dotnetnuke based website?
In the ordinal web page to change programmatically the title of the .aspx page is simple:
In dotnetnuke's module that code will not help. The title of the web page will be created by DNN's core.
But we can solve this problem. The code below shows how to achieve this:
protected void Page_Load(object sender, EventArgs e)
{
this.Title = "The ordinal web page";
}
In dotnetnuke's module that code will not help. The title of the web page will be created by DNN's core.
But we can solve this problem. The code below shows how to achieve this:
Ярлыки:
ASP.NET,
C#,
CMS,
DNN,
dotnetnuke,
Page.Title,
programming,
title,
web page,
website
Tuesday, February 3, 2009
LINQ to SQL: How to get a Random Record from a Table inside the SQL Server Database
I wanted to get a random record from a particular table on the SQL Server database. For my case, I had a table containing quotes, and I wanted to randomly pick on to show on one corner of my web site. I am also using LINQ to SQL for this web site, so the solution here will be using LINQ, although the approach is pretty simple and flexible.
The idea centers on ordering the records by a random parameter an then getting the TOP n number of records. The NEWID() function from SQL Server makes a great candidate for getting a random parameter since this method generates a GUID.
In SQL Server, try out this query.
The idea centers on ordering the records by a random parameter an then getting the TOP n number of records. The NEWID() function from SQL Server makes a great candidate for getting a random parameter since this method generates a GUID.
In SQL Server, try out this query.
SELECT * FROM Quote ORDER by NEWID();
SELECT TOP 1 * FROM Quote ORDER by NEWID();
Wednesday, October 29, 2008
Нow to dynamically change query for ListView linked to LinqDataSource?
In order to dynamically change query for ListView linked to LinqDataSource you have to handle OnSelecting event for LinqDataSource. .
For example:
How does it works you can see here: 11-A
For example:
protected void dsMates_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
if (Request.Params["classMateId"] != null)
{
int mateId;
if (int.TryParse(Request.Params["classMateId"], out mateId))
{
using (DataClassesPrivateMsgDataContext db = new DataClassesPrivateMsgDataContext())
{
e.Result = db.Classmates.Where(mate => mate.Id == mateId).FirstOrDefault();
}
}
}
}
How does it works you can see here: 11-A
Ярлыки:
.NET framework 3.5,
ASP.NET,
C#,
code,
LinqDataSource,
ListView,
OnSelecting,
Query
Wednesday, October 22, 2008
Code formatter for C#, JavaScript, HTML, ASP.NET for your blog
When posting posts to my blog often need to insert some code saples into the text. It's good to show well formatted code for readers.
If found good free online tool for my purposes:
www.manoli.net/csharpformat/format.aspx
This tool allows you to format your C#, VB, HTML, XML, T-SQL or MSH (code name Monad) code for publishing on a web site or in a blog.
All welcome!
If found good free online tool for my purposes:
www.manoli.net/csharpformat/format.aspx
This tool allows you to format your C#, VB, HTML, XML, T-SQL or MSH (code name Monad) code for publishing on a web site or in a blog.
All welcome!
Ярлыки:
blog,
blogging,
C#,
code,
formatter,
HTML,
javaScript,
programming
Subscribe to:
Posts (Atom)