Click here to Skip to main content
15,912,082 members
Home / Discussions / C#
   

C#

 
AnswerRe: Connect to VPN server Pin
stancrm31-Aug-09 8:16
stancrm31-Aug-09 8:16 
GeneralRe: Connect to VPN server Pin
yogesh_softworld12331-Aug-09 19:59
yogesh_softworld12331-Aug-09 19:59 
GeneralRe: Connect to VPN server Pin
stancrm31-Aug-09 20:31
stancrm31-Aug-09 20:31 
QuestionButton inside a textbox? Pin
SevM31-Aug-09 4:31
SevM31-Aug-09 4:31 
AnswerRe: Button inside a textbox? Pin
EliottA31-Aug-09 4:52
EliottA31-Aug-09 4:52 
AnswerRe: Button inside a textbox? Pin
monstale31-Aug-09 4:55
monstale31-Aug-09 4:55 
GeneralRe: Button inside a textbox? Pin
EliottA31-Aug-09 5:07
EliottA31-Aug-09 5:07 
AnswerRe: Button inside a textbox? Pin
Henry Minute31-Aug-09 5:34
Henry Minute31-Aug-09 5:34 
Questioninvoke event from diffrent class hierarchy Pin
Ronenb31-Aug-09 3:41
Ronenb31-Aug-09 3:41 
AnswerRe: invoke event from diffrent class hierarchy Pin
Henry Minute31-Aug-09 5:50
Henry Minute31-Aug-09 5:50 
QuestionHow to add the scroll bar Pin
Fired.Fish.Gmail31-Aug-09 2:44
Fired.Fish.Gmail31-Aug-09 2:44 
QuestionLog Off Computer Fails Pin
Abdul Rahman Hamidy31-Aug-09 2:11
Abdul Rahman Hamidy31-Aug-09 2:11 
AnswerRe: Log Off Computer Fails Pin
monstale31-Aug-09 2:56
monstale31-Aug-09 2:56 
GeneralRe: Log Off Computer Fails Pin
Abdul Rahman Hamidy1-Sep-09 18:25
Abdul Rahman Hamidy1-Sep-09 18:25 
GeneralRe: Log Off Computer Fails [modified] Pin
monstale1-Sep-09 22:55
monstale1-Sep-09 22:55 
GeneralRe: Log Off Computer Fails Pin
Abdul Rahman Hamidy1-Sep-09 23:48
Abdul Rahman Hamidy1-Sep-09 23:48 
GeneralRe: Log Off Computer Fails Pin
monstale2-Sep-09 0:51
monstale2-Sep-09 0:51 
GeneralRe: Log Off Computer Fails Pin
Abdul Rahman Hamidy2-Sep-09 0:55
Abdul Rahman Hamidy2-Sep-09 0:55 
GeneralRe: Log Off Computer Fails Pin
Vishwamr150619-Sep-09 9:04
Vishwamr150619-Sep-09 9:04 
QuestionRGB-Byte[] to BGR-Bitmap? Pin
blacksheep131-Aug-09 2:09
blacksheep131-Aug-09 2:09 
AnswerRe: RGB-Byte[] to BGR-Bitmap? Pin
Henry Minute31-Aug-09 2:22
Henry Minute31-Aug-09 2:22 
GeneralRe: RGB-Byte[] to BGR-Bitmap? Pin
blacksheep131-Aug-09 2:51
blacksheep131-Aug-09 2:51 
GeneralRe: RGB-Byte[] to BGR-Bitmap? Pin
Henry Minute31-Aug-09 5:08
Henry Minute31-Aug-09 5:08 
I have put your test image generator code into a Windows Forms Application and I get a vertical RED stripe, then a vertical GREEN stripe then a vertical BLUE stripe. This is what I would expect.

Here is my code:
public partial class ByteArrayToImageForm : Form
{
    private int f_WIDTH = 100;
    private int f_HEIGHT = 100;
    private byte[] testImageArray;

    public ByteArrayToImageForm()
    {
        InitializeComponent();

        this.testImageArray = this.MakeImage();
    }

    public byte[] MakeImage()
    {
        int x = 0;
        byte[] Img = new Byte[f_WIDTH * f_HEIGHT * 3];
        for (int i = 0; i < f_WIDTH * f_HEIGHT * 3; i += 3, x++)
        {
            if (x == f_WIDTH)
            {
                x = 0;
            }
            if (x <= f_WIDTH / 3)
            {
                Img[i] = 255;
                Img[i + 1] = 0;
                Img[i + 2] = 0;
            }
            if (x > f_WIDTH / 3 && x < (f_WIDTH / 3) * 2)
            {
                Img[i] = 0;
                Img[i + 1] = 255;
                Img[i + 2] = 0;
            }
            if (x > (f_WIDTH / 3) * 2)
            {
                Img[i] = 0;
                Img[i + 1] = 0;
                Img[i + 2] = 255;
            }
        }
        return Img;
    }

    private void ByteArrayToImageForm_Paint(object sender, PaintEventArgs e)
    {
        int arrayIndex = 0;
        int x = 0;
        int y = 0;

        Bitmap visibleBitmap = new Bitmap(this.f_WIDTH, this.f_HEIGHT, PixelFormat.Format24bppRgb);
        while (arrayIndex < this.testImageArray.Length)
        {
            visibleBitmap.SetPixel(x, y,
                Color.FromArgb(this.testImageArray[arrayIndex],
                this.testImageArray[arrayIndex + 1],
                this.testImageArray[arrayIndex + 2]));
            x++;
            if (x >= this.f_WIDTH)
            {
                x = 0;
                y++;
            }
            arrayIndex += 3;
        }

        int drawX = (this.ClientRectangle.Width - visibleBitmap.Width) / 2;
        int drawY = (this.ClientRectangle.Height - visibleBitmap.Height) / 2;

        e.Graphics.DrawImage(visibleBitmap, drawX, drawY);
    }
}


Try it out. **NOTE** I have dispensed with the Convert.ToByte parts from your code as they are not necessary, although it does not alter the output (I tried both ways).

So unless you were using Convert.ToByte because you were converting from int, for example, which might explain your problems, I am at a loss.

Sorry! Smile | :)

Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”

QuestionVisual Studio 2005 - Create Cubes with Analysis Services Pin
Mschauder31-Aug-09 1:37
Mschauder31-Aug-09 1:37 
AnswerRe: Visual Studio 2005 - Create Cubes with Analysis Services Pin
monstale31-Aug-09 2:09
monstale31-Aug-09 2:09 

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.