I download an image to a PictureBox using
PHP Code
<?php pictureBox1.ImageLocation = "url";
It downloads an image that's 64 by 32, but my PictureBox is 256 by 128.
I have the SizeMode property set to StretchImage.
StretchImage works fine, except it blurs the edges between pixels, I need this to look pixely.
I've read a lot of answers to this questions, they all say that you need to use the Graphics class but I haven't seen any code example that have worked.
Can someone here give me the code to make the result look pixely?
Thanks a bunch 🙂
Sep 29, 2012 04:01 PM
(This post was last modified: Sep 29, 2012 04:11 PM by n0pcode.)
What you do is basically every pixel times 4, but since we have modern displays it doesn't look pixelated but blurry indeed.
If you want your image to be pixelated you'll have to delete (or skip) pixels, this is quite interesting. let me try something out.
EDIT: Could you PM me or link the image here ? So I got something to work with...
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
(Sep 29, 2012 04:01 PM)n0pcode Wrote: What you do is basically every pixel times 4, but since we have modern displays it doesn't look pixelated but blurry indeed.
If you want your image to be pixelated you'll have to delete (or skip) pixels, this is quite interesting. let me try something out.
EDIT: Could you PM me or link the image here ? So I got something to work with...
Alright, cool.
Hope you come up with something :)
I was bored so I came up with something, not sure if it's the best way to do this but I hope it'll help.
Code private Image pixelate(Image img, int finalWidth, int finalHeight)
{
Bitmap b = (Bitmap)img;
Size ratio = new Size(finalWidth / b.Width, finalHeight / b.Height);
Bitmap bp = new Bitmap(b.Width * ratio.Width, b.Height * ratio.Height);
Graphics g = Graphics.FromImage(bp);
for (int y = 0; y < b.Height; y++)
{
for (int x = 0; x < b.Width; x++)
{
g.FillRectangle(new SolidBrush(b.GetPixel(x, y)), new Rectangle(new Point(x * ratio.Width, y * ratio.Height), ratio));
}
}
return (Image)bp;
}
Here's comparsion
(Sep 29, 2012 04:32 PM)Pussy Cat Wrote: I was bored so I came up with something, not sure if it's the best way to do this but I hope it'll help.
Code private Image pixelate(Image img, int finalWidth, int finalHeight)
{
Bitmap b = (Bitmap)img;
Size ratio = new Size(finalWidth / b.Width, finalHeight / b.Height);
Bitmap bp = new Bitmap(b.Width * ratio.Width, b.Height * ratio.Height);
Graphics g = Graphics.FromImage(bp);
for (int y = 0; y < b.Height; y++)
{
for (int x = 0; x < b.Width; x++)
{
g.FillRectangle(new SolidBrush(b.GetPixel(x, y)), new Rectangle(new Point(x * ratio.Width, y * ratio.Height), ratio));
}
}
return (Image)bp;
}
Here's comparsion
![[Image: 19Rbt]](https://puu.sh/19Rbt)
It works like a dream, thanks man :D
Check your rep
Can I asked why you needed to do this? It just seems like something dumb unless you are doing what I think your doing.
(Sep 29, 2012 04:54 PM)Linux. Wrote: Can I asked why you needed to do this? It just seems like something dumb unless you are doing what I think your doing.
What do you think I'm doing? I wanna know 😝
I'll post a thread about this project in a minute.
Sep 29, 2012 04:57 PM
(This post was last modified: Sep 29, 2012 04:57 PM by Linux..)
Some type of color detection program or something? Maybe something to fix the pixels so they fix themselves when re-sized.
(Sep 29, 2012 04:57 PM)Linux. Wrote: Some type of color detection program or something? Maybe something to fix the pixels so they fix themselves when re-sized.
It's actually a skin stealer for Minecraft :P
(Sep 29, 2012 04:59 PM)Quad Wrote: It's actually a skin stealer for Minecraft :P
Really? How the hell? Add me on Skype austin--sweat 🤝
(Sep 29, 2012 04:59 PM)Quad Wrote: It's actually a skin stealer for Minecraft :P
May i ask why you need to pixelate an image if you want to steal a skin? You mean from other people? if so you can just download the image from http://minecraft.net/skin/PersonsName*can use textbox to change if wanted*.png, course then again that's when minecraft.net is actually up :P
Sep 29, 2012 06:44 PM
(This post was last modified: Sep 29, 2012 06:44 PM by Quad.)
(Sep 29, 2012 06:29 PM)Debroski Wrote: May i ask why you need to pixelate an image if you want to steal a skin? You mean from other people? if so you can just download the image from http://minecraft.net/skin/PersonsName*can use textbox to change if wanted*.png, course then again that's when minecraft.net is actually up :P
I want to display it nicely. msg ...
|