Click here to Skip to main content
15,920,383 members
Home / Discussions / C#
   

C#

 
AnswerRe: CTL+A Detection Pin
Andrew Lygin8-Jul-06 20:42
Andrew Lygin8-Jul-06 20:42 
AnswerRe: CTL+A Detection Pin
Super Lloyd8-Jul-06 22:01
Super Lloyd8-Jul-06 22:01 
QuestionMouse Position on startup Pin
StyrofoamSUV8-Jul-06 12:52
StyrofoamSUV8-Jul-06 12:52 
AnswerRe: Mouse Position on startup Pin
Ravi Bhavnani8-Jul-06 14:03
professionalRavi Bhavnani8-Jul-06 14:03 
GeneralRe: Mouse Position on startup Pin
StyrofoamSUV9-Jul-06 7:24
StyrofoamSUV9-Jul-06 7:24 
Questionsemi-transparent image Pin
alexiev_nikolay8-Jul-06 11:50
alexiev_nikolay8-Jul-06 11:50 
GeneralRe: semi-transparent image Pin
Guffa8-Jul-06 11:55
Guffa8-Jul-06 11:55 
AnswerRe: semi-transparent image Pin
Robert Rohde8-Jul-06 12:19
Robert Rohde8-Jul-06 12:19 
Hi,

I've done that in one of my articles. The following code applies an alpha value to a bitmap:
private unsafe void ApplyAlphaToImage(Bitmap image)
{
   if (image == null || _alpha == 255)
      return;

   int imageWidth = image.Width;
   int imageHeight = image.Height;

   BitmapData data = null;
   try 
   {
      data = image.LockBits(new Rectangle(0, 0, imageWidth, imageHeight), 
         ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
      int scan0 = data.Scan0.ToInt32();
      int stride = data.Stride;

      byte * colPixel;

      byte invertedAlpha = (byte)(255 - _alpha);

      byte * rowPixel = (byte *)scan0;
      for (int y = 0; y < imageHeight; y++)
      {
         colPixel = rowPixel + 3;
         for (int x = 0; x < imageWidth; x++)
         {
            if (*(colPixel) < invertedAlpha)
               *(colPixel) = 0;
            else
               *(colPixel) = (byte)(*(colPixel) - invertedAlpha);
            colPixel += 4;
         }
         rowPixel += stride;
      }
   } 
   finally 
   {
      if (data != null)
         image.UnlockBits(data);
   }
}

This is still pixel by pixel but not using the regular Get/SetPixel functions but LockBits unsafe code. It is relatively fast - fast enough at least so I could use it in animations. Look here[^] to see the results.
QuestionScanning the memory of another process - where do i start searching? Pin
bunnyEATINGrabbit8-Jul-06 11:39
bunnyEATINGrabbit8-Jul-06 11:39 
AnswerRe: Scanning the memory of another process - where do i start searching? Pin
leppie8-Jul-06 22:25
leppie8-Jul-06 22:25 
Questiondrag and drop Pin
erfi8-Jul-06 8:29
erfi8-Jul-06 8:29 
AnswerRe: drag and drop Pin
mav.northwind8-Jul-06 9:45
mav.northwind8-Jul-06 9:45 
AnswerRe: drag and drop Pin
Robert Rohde8-Jul-06 12:20
Robert Rohde8-Jul-06 12:20 
Questionprogress bar [modified] Pin
Squee!8-Jul-06 8:29
Squee!8-Jul-06 8:29 
AnswerRe: progress bar Pin
Martin238-Jul-06 11:40
Martin238-Jul-06 11:40 
Questioncombobox value acess.......???? [modified] Pin
Nagraj Naik8-Jul-06 3:02
Nagraj Naik8-Jul-06 3:02 
AnswerRe: combobox value acess.......???? Pin
Guffa8-Jul-06 5:16
Guffa8-Jul-06 5:16 
AnswerRe: combobox value acess.......???? Pin
albCode9-Jul-06 2:14
albCode9-Jul-06 2:14 
AnswerRe: combobox value acess.......???? Pin
Nagraj Naik9-Jul-06 19:58
Nagraj Naik9-Jul-06 19:58 
QuestionVideo Size Pin
J.S.Lim8-Jul-06 2:10
J.S.Lim8-Jul-06 2:10 
QuestionRichTextBox Help Required !! [modified] Pin
Shinning Star8-Jul-06 0:04
Shinning Star8-Jul-06 0:04 
AnswerRe: RichTextBox Help Required !! Pin
mav.northwind8-Jul-06 7:29
mav.northwind8-Jul-06 7:29 
Questionhow to get CPU n RAM information from machines Pin
amber hussain7-Jul-06 23:42
amber hussain7-Jul-06 23:42 
AnswerRe: how to get CPU n RAM information from machines Pin
Eran Aharonovich8-Jul-06 2:15
Eran Aharonovich8-Jul-06 2:15 
AnswerRe: how to get CPU n RAM information from machines Pin
yoaz8-Jul-06 3:17
yoaz8-Jul-06 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.