Hey guys I was wondering if I had a sprite-sheet and I wanted to load only a certain 32x32 region of it into a 'PictureBox' of a Windows Form, how would I go about doing that? Also as a bonus, how would I filter the Magenta(255,0,255) and render as alpha, like SDL colour-keying. NOTE: I'm not too bothered about the second question, as that can be done somewhat manually by creating a magenta to alpha program.
Thanks in advance.
Visual C# Windows Forms PictureBox Clipping and Color Filter
Moderator: Coders of Rage
- OmenFelix
- Chaos Rift Cool Newbie
- Posts: 59
- Joined: Fri May 04, 2012 1:42 pm
- Current Project: Arcadian Descent(C++, SDL, KOS)
- Favorite Gaming Platforms: PS2, PC, XBOX, NDS
- Programming Language of Choice: C/C++
Visual C# Windows Forms PictureBox Clipping and Color Filter
Why not check out my game-development forum at: http://f1rel0ck.netai.net
Or my 2D RPG at: https://www.facebook.com/pages/Arcadian ... 6873806531
Or my 2D RPG at: https://www.facebook.com/pages/Arcadian ... 6873806531
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Visual C# Windows Forms PictureBox Clipping and Color Fi
A better questions is why would you want to do that? I hope this is an editor question..
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- OmenFelix
- Chaos Rift Cool Newbie
- Posts: 59
- Joined: Fri May 04, 2012 1:42 pm
- Current Project: Arcadian Descent(C++, SDL, KOS)
- Favorite Gaming Platforms: PS2, PC, XBOX, NDS
- Programming Language of Choice: C/C++
Re: Visual C# Windows Forms PictureBox Clipping and Color Fi
Yes it is. It's only a temporary measure as none of the team really have experience with editors nor want to do much about it. Just to test the tiling system really.dandymcgee wrote:A better questions is why would you want to do that? I hope this is an editor question..
Why not check out my game-development forum at: http://f1rel0ck.netai.net
Or my 2D RPG at: https://www.facebook.com/pages/Arcadian ... 6873806531
Or my 2D RPG at: https://www.facebook.com/pages/Arcadian ... 6873806531
-
- Chaos Rift Junior
- Posts: 204
- Joined: Mon Nov 21, 2011 3:01 pm
- Current Project: Web browser from scratch
- Favorite Gaming Platforms: SNES, PSP, PS1 and 3
- Programming Language of Choice: C#
- Location: A house near me
- Contact:
Re: Visual C# Windows Forms PictureBox Clipping and Color Fi
You could use cropping?OmenFelix wrote:Hey guys I was wondering if I had a sprite-sheet and I wanted to load only a certain 32x32 region of it into a 'PictureBox' of a Windows Form, how would I go about doing that? Also as a bonus, how would I filter the Magenta(255,0,255) and render as alpha, like SDL colour-keying. NOTE: I'm not too bothered about the second question, as that can be done somewhat manually by creating a magenta to alpha program.
Thanks in advance.
Code: Select all
Bitmap bmp = new Bitmap(32,32);
//Draw the spritesheet bitmap
Graphics.DrawImage(spritesheet, new Rectangle(-spiteX, -spriteY, 32, 32));
//Set the picture box image and size
pictureBox.Image = bmp;
pictureBox.Size = bmp.Size;
It'l do the job...
This however may not be the best way to go about this since I'm not sure than rendering the spritesheet for every sprite is as-efficent.
You could also use
Code: Select all
Bitmap mySprite = (Bitmap)spritesheet.Clone(new Rectangle(spriteX, spriteY, 32,32), PixelFormat.Gdi);
- OmenFelix
- Chaos Rift Cool Newbie
- Posts: 59
- Joined: Fri May 04, 2012 1:42 pm
- Current Project: Arcadian Descent(C++, SDL, KOS)
- Favorite Gaming Platforms: PS2, PC, XBOX, NDS
- Programming Language of Choice: C/C++
Re: Visual C# Windows Forms PictureBox Clipping and Color Fi
This code isn't for a PictureBox is it?tappatekie wrote:You could use cropping?OmenFelix wrote:Hey guys I was wondering if I had a sprite-sheet and I wanted to load only a certain 32x32 region of it into a 'PictureBox' of a Windows Form, how would I go about doing that? Also as a bonus, how would I filter the Magenta(255,0,255) and render as alpha, like SDL colour-keying. NOTE: I'm not too bothered about the second question, as that can be done somewhat manually by creating a magenta to alpha program.
Thanks in advance.
spriteX and spriteY is negative since we want to offset the render of the main sprite image and select 32x32 pixels of it.Code: Select all
Bitmap bmp = new Bitmap(32,32); //Draw the spritesheet bitmap Graphics.DrawImage(spritesheet, new Rectangle(-spiteX, -spriteY, 32, 32)); //Set the picture box image and size pictureBox.Image = bmp; pictureBox.Size = bmp.Size;
It'l do the job...
This however may not be the best way to go about this since I'm not sure than rendering the spritesheet for every sprite is as-efficent.
You could also useCode: Select all
Bitmap mySprite = (Bitmap)spritesheet.Clone(new Rectangle(spriteX, spriteY, 32,32), PixelFormat.Gdi);
Why not check out my game-development forum at: http://f1rel0ck.netai.net
Or my 2D RPG at: https://www.facebook.com/pages/Arcadian ... 6873806531
Or my 2D RPG at: https://www.facebook.com/pages/Arcadian ... 6873806531
-
- Chaos Rift Junior
- Posts: 204
- Joined: Mon Nov 21, 2011 3:01 pm
- Current Project: Web browser from scratch
- Favorite Gaming Platforms: SNES, PSP, PS1 and 3
- Programming Language of Choice: C#
- Location: A house near me
- Contact:
Re: Visual C# Windows Forms PictureBox Clipping and Color Fi
You can apply the code to a picture box... with "pictureBox.Image = croppedBitmap;", the cropped bitmap would be the mySprite bit in the code...OmenFelix wrote:This code isn't for a PictureBox is it?tappatekie wrote:You could use cropping?OmenFelix wrote:Hey guys I was wondering if I had a sprite-sheet and I wanted to load only a certain 32x32 region of it into a 'PictureBox' of a Windows Form, how would I go about doing that? Also as a bonus, how would I filter the Magenta(255,0,255) and render as alpha, like SDL colour-keying. NOTE: I'm not too bothered about the second question, as that can be done somewhat manually by creating a magenta to alpha program.
Thanks in advance.
spriteX and spriteY is negative since we want to offset the render of the main sprite image and select 32x32 pixels of it.Code: Select all
Bitmap bmp = new Bitmap(32,32); //Draw the spritesheet bitmap Graphics.DrawImage(spritesheet, new Rectangle(-spiteX, -spriteY, 32, 32)); //Set the picture box image and size pictureBox.Image = bmp; pictureBox.Size = bmp.Size;
It'l do the job...
This however may not be the best way to go about this since I'm not sure than rendering the spritesheet for every sprite is as-efficent.
You could also useCode: Select all
Bitmap mySprite = (Bitmap)spritesheet.Clone(new Rectangle(spriteX, spriteY, 32,32), PixelFormat.Gdi);
Unless you want the picturebox to only show a certain part of the image (spritesheet) with the picture box image property set to the spritesheet image, if so, please be more specific, you said to "load only a certain 32x32 region of it into a 'PictureBox' " ("INTO"...)
- OmenFelix
- Chaos Rift Cool Newbie
- Posts: 59
- Joined: Fri May 04, 2012 1:42 pm
- Current Project: Arcadian Descent(C++, SDL, KOS)
- Favorite Gaming Platforms: PS2, PC, XBOX, NDS
- Programming Language of Choice: C/C++
Re: Visual C# Windows Forms PictureBox Clipping and Color Fi
Thanks! I'll try it later. :3tappatekie wrote:You can apply the code to a picture box... with "pictureBox.Image = croppedBitmap;", the cropped bitmap would be the mySprite bit in the code...OmenFelix wrote:This code isn't for a PictureBox is it?tappatekie wrote:You could use cropping?OmenFelix wrote:Hey guys I was wondering if I had a sprite-sheet and I wanted to load only a certain 32x32 region of it into a 'PictureBox' of a Windows Form, how would I go about doing that? Also as a bonus, how would I filter the Magenta(255,0,255) and render as alpha, like SDL colour-keying. NOTE: I'm not too bothered about the second question, as that can be done somewhat manually by creating a magenta to alpha program.
Thanks in advance.
spriteX and spriteY is negative since we want to offset the render of the main sprite image and select 32x32 pixels of it.Code: Select all
Bitmap bmp = new Bitmap(32,32); //Draw the spritesheet bitmap Graphics.DrawImage(spritesheet, new Rectangle(-spiteX, -spriteY, 32, 32)); //Set the picture box image and size pictureBox.Image = bmp; pictureBox.Size = bmp.Size;
It'l do the job...
This however may not be the best way to go about this since I'm not sure than rendering the spritesheet for every sprite is as-efficent.
You could also useCode: Select all
Bitmap mySprite = (Bitmap)spritesheet.Clone(new Rectangle(spriteX, spriteY, 32,32), PixelFormat.Gdi);
Unless you want the picturebox to only show a certain part of the image (spritesheet) with the picture box image property set to the spritesheet image, if so, please be more specific, you said to "load only a certain 32x32 region of it into a 'PictureBox' " ("INTO"...)
Why not check out my game-development forum at: http://f1rel0ck.netai.net
Or my 2D RPG at: https://www.facebook.com/pages/Arcadian ... 6873806531
Or my 2D RPG at: https://www.facebook.com/pages/Arcadian ... 6873806531