EntropiaForum.com
Go Back   EntropiaForum.com > Non EU Related > Off topic
Notice
Off topic Chat about anything not related to EntropiaUniverse.

Reply
 
LinkBack Thread Tools
Old 08-03-2007, 10:13   #1
Elite
Witte's Avatar
Witte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte Expert  
  Activity Longevity
2/2018/20
Posts: 4,249
Gender: Male Ingame: Male
Avatar Name:
Vlugge Witte Harrie
Soc: Delta Force Elite
Reputation: Expert
Fame: 84 Achievements: 1
Style: Segna Chomper
Creating thumbs (in ASP.NET)

Maybe anyone here has experience with this. When create thumbs in ASP.NET using the standard bitmap class the result will look like this:
When I zoom out the picture in PSP it looks like this:

I also tried using the internal resize methods (Smartsize, Bicubic, Bilinear etc) in PSP but those all have worse results. It seems when zooming out, PSP is using windows resizing algorithms or something. Does anyone know what method is used? And does anyone know if I can also use that method in ASP.NET? I tried searching on google but didnt realy know where to start looking.
__________________
Member of Delta Force Elite and admin of Entropedia
Witte is offline Reply With Quote
Sponsored Links
Old 08-03-2007, 10:55   #2
Old Alpha
KP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 Competent  
  Activity Longevity
0/209/20
Posts: 948
Gender: Male Ingame: Male
Soc: Terra Verde
Location: UK
Reputation: Competent
Fame: 37 Achievements: 2
Style: Zychion Battle

Quote:
Originally Posted by Witte View Post
Maybe anyone here has experience with this. When create thumbs in ASP.NET using the standard bitmap class the result will look like this:
When I zoom out the picture in PSP it looks like this:

I also tried using the internal resize methods (Smartsize, Bicubic, Bilinear etc) in PSP but those all have worse results. It seems when zooming out, PSP is using windows resizing algorithms or something. Does anyone know what method is used? And does anyone know if I can also use that method in ASP.NET? I tried searching on google but didnt realy know where to start looking.
I'm a bit confused here.

Are you saying that the asp.net bitmap class produces rubbish results when you scale an image down to a smaller (thumbnail) size, and you want to get better results?

I'm pretty sure PSP uses an antialiased technique to scale images down, whereas the .net Bitmap.GetThumbnailImage will most likely not.

Can you maybe do the scaling youself - create a Graphics object associated with an in-memory DC (ie your target thumbnail bitmap) and set the Graphics.SmoothingMode property to achieve antialised/smoothed drawing. Render your original onto the new Graphics object using the DrawImage method, with the target rectangle specified to scale it down, then you have your new scaled thumbnail bitmap.

I don't know if this is what you were after, but it might help.
__________________
KP's current objective: looting pixie feet, 1200SG
Achieved objectives: 1000 SG, 200 Conc
KP708 is offline Reply With Quote
Old 08-03-2007, 11:02   #3
Elite
Witte's Avatar
Witte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte Expert  
  Activity Longevity
2/2018/20
Posts: 4,249
Gender: Male Ingame: Male
Avatar Name:
Vlugge Witte Harrie
Soc: Delta Force Elite
Reputation: Expert
Fame: 84 Achievements: 1
Style: Segna Chomper

Quote:
Originally Posted by KP708 View Post
I'm a bit confused here.

Are you saying that the asp.net bitmap class produces rubbish results when you scale an image down to a smaller (thumbnail) size, and you want to get better results?

I'm pretty sure PSP uses an antialiased technique to scale images down, whereas the .net Bitmap.GetThumbnailImage will most likely not.

Can you maybe do the scaling youself - create a Graphics object associated with an in-memory DC (ie your target thumbnail bitmap) and set the Graphics.SmoothingMode property to achieve antialised/smoothed drawing. Render your original onto the new Graphics object using the DrawImage method, with the target rectangle specified to scale it down, then you have your new scaled thumbnail bitmap.

I don't know if this is what you were after, but it might help.
I am indeed after a better result I will give your suggestion a try, tnx. I will report later if it works.

EDIT: Hmm I cant find this SmoothingMode property at all. Is is a standard property?
EDIT2: nm, found it

Last edited by Witte; 08-03-2007 at 11:14..
Witte is offline Reply With Quote
Old 08-03-2007, 11:11   #4
Nakia's Property & l t;3 Love You
MrSmith's Avatar
Become a premium member today and enjoy enhanced EntropiaForum features!
MrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith Good  
  Activity Longevity
0/2014/20
Posts: 1,207
Gender: Male Ingame: Male
Avatar Name:
Loke MrSmith Smith
Soc: Novus Ordo Seclorum
Location: In the arms of Nakia
Reputation: Good
Fame: 1148 Achievements: 6
Style: TI Second Entity
In C# code

Use the System.Drawing.Imaging library

Quote:
using System.Drawing;
using System.Drawing.Imaging;
Reading the images in

Quote:
System.Drawing.Image myimage;
string image_filename=@"c:\location\of\my\image";
try
{
myimage = System.Drawing.Image.FromFile(image_filename);
}
catch
{
Response.Write("Couldn't open file" + image_filename + "<br>");
return;
}
Creating the thumbnail bitmap

Quote:
Bitmap source_bitmap = new Bitmap(myimage);
Bitmap thumb_bitmap = new Bitmap(thumb_width, thumb_height);
Graphics g = Graphics.FromImage(thumb_bitmap);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQua lityBicubic;
g.FillRectangle(Brushes.White, 0, 0, thumb_width, thumb_height);
g.DrawImage(source_bitmap, 0, 0, thumb_width, thumb_height);

Saving the thumbnail to disk


Quote:
ImageCodecInfo[] Info = ImageCodecInfo.GetImageEncoders();
EncoderParameters Params = new EncoderParameters(1);
Params.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Qu ality, 100L);
thumb_bitmap.Save(thumb_filename, Info[1], Params);

Last edited by MrSmith; 08-03-2007 at 11:16..
__________________
MrSmith is offline Reply With Quote
Old 08-03-2007, 11:31   #5
Old Alpha
KP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 Competent  
  Activity Longevity
0/209/20
Posts: 948
Gender: Male Ingame: Male
Soc: Terra Verde
Location: UK
Reputation: Competent
Fame: 37 Achievements: 2
Style: Zychion Battle

Quote:
Originally Posted by MrSmith View Post
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQua lityBicubic;
I always thought the interpolation mode was only used for filling in extra pixels when making a bmp larger, and not for shrinking.

Hence why I thought set g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias

But I could be wrong here. Maybe it only uses antialiasing for drawing primitives like lines and not for bmp scaling.

I'd be interested to know what you find works.
KP708 is offline Reply With Quote
Old 08-03-2007, 11:35   #6
Elite
Witte's Avatar
Witte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte Expert  
  Activity Longevity
2/2018/20
Posts: 4,249
Gender: Male Ingame: Male
Avatar Name:
Vlugge Witte Harrie
Soc: Delta Force Elite
Reputation: Expert
Fame: 84 Achievements: 1
Style: Segna Chomper

Tnx for all input. I will try the different modes and see what gives the best result. Although I am currently figuring out how to write the graphics object to a stream (I know im noob at this hehe)

My code so far:

Code:
                using (Bitmap bmp = new Bitmap(img, width, height))
                {
                    Graphics g = Graphics.FromImage(bmp);
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                    g.FillRectangle(Brushes.Transparent, 0, 0, fwidth, fheight);
                    g.DrawImage(img, (fwidth-width)/2, (fheight-height)/2, width, height);
                    MemoryStream mstream = new MemoryStream();
\
                    return mstream;
                }
Witte is offline Reply With Quote
Old 08-03-2007, 11:37   #7
Nakia's Property &amp;amp;amp;amp;amp;amp;amp; l t;3 Love You
MrSmith's Avatar
Become a premium member today and enjoy enhanced EntropiaForum features!
MrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith GoodMrSmith Good  
  Activity Longevity
0/2014/20
Posts: 1,207
Gender: Male Ingame: Male
Avatar Name:
Loke MrSmith Smith
Soc: Novus Ordo Seclorum
Location: In the arms of Nakia
Reputation: Good
Fame: 1148 Achievements: 6
Style: TI Second Entity

Quote:
Originally Posted by KP708 View Post
I always thought the interpolation mode was only used for filling in extra pixels when making a bmp larger, and not for shrinking.

Hence why I thought set g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias

But I could be wrong here. Maybe it only uses antialiasing for drawing primitives like lines and not for bmp scaling.

I'd be interested to know what you find works.
Interpolation modes use different algorithms to resample the original image for its new size and try to render as close as possible in the new resolution.
Most image manipulation programs like Photoshop and PaintShop Pro support many of the same Interpolation modes. So both for making image smaller and larger
MrSmith is offline Reply With Quote
Old 08-03-2007, 11:52   #8
Old Alpha
KP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 CompetentKP708 Competent  
  Activity Longevity
0/209/20
Posts: 948
Gender: Male Ingame: Male
Soc: Terra Verde
Location: UK
Reputation: Competent
Fame: 37 Achievements: 2
Style: Zychion Battle

Quote:
Originally Posted by MrSmith View Post
Interpolation modes use different algorithms to resample the original image for its new size and try to render as close as possible in the new resolution.
Most image manipulation programs like Photoshop and PaintShop Pro support many of the same Interpolation modes. So both for making image smaller and larger
Well well there you go... Learn a new thing every day

To save it to a stream witte

bmp.Save(mstream, ImageFormat.xxxxxx)

ought to work.

I used this to write an on-the-fly created bmp directly to the output stream in asp.net. ie you can put Response.OutputStream where I put mstream above. But I think using your memory stream would work too.

xxxxx can be whatever format you want - see the ImageFormat enum. Jpeg, gif, whatever.

hf
KP708 is offline Reply With Quote
Old 08-03-2007, 11:57   #9
Elite
Witte's Avatar
Witte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte Expert  
  Activity Longevity
2/2018/20
Posts: 4,249
Gender: Male Ingame: Male
Avatar Name:
Vlugge Witte Harrie
Soc: Delta Force Elite
Reputation: Expert
Fame: 84 Achievements: 1
Style: Segna Chomper

Quote:
Originally Posted by KP708 View Post
Well well there you go... Learn a new thing every day

To save it to a stream witte

bmp.Save(mstream, ImageFormat.xxxxxx)

ought to work.

I used this to write an on-the-fly created bmp directly to the output stream in asp.net. ie you can put Response.OutputStream where I put mstream above. But I think using your memory stream would work too.

xxxxx can be whatever format you want - see the ImageFormat enum. Jpeg, gif, whatever.


hf
yup tnx, i already figured that out hehe. the result should be visible on www.entropedia.info soon

Tnx allot all.
Witte is offline Reply With Quote
Old 08-03-2007, 12:58   #10
Elite
Witte's Avatar
Witte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte ExpertWitte Expert  
  Activity Longevity
2/2018/20
Posts: 4,249
Gender: Male Ingame: Male
Avatar Name:
Vlugge Witte Harrie
Soc: Delta Force Elite
Reputation: Expert
Fame: 84 Achievements: 1
Style: Segna Chomper

It doesnt realy work as it should, the resulting image doesnt resize. My code looks like this:

Code:
                
using (Bitmap bmp = new Bitmap(img))
{
  Graphics g = Graphics.FromImage(bmp);
  //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
  g.FillRectangle(Brushes.Transparent, 0, 0, fwidth, fheight);
  g.DrawImage(bmp, (fwidth-width)/2, (fheight-height)/2, width, height);
  MemoryStream mstream = new MemoryStream();
  bmp.Save(mstream, ImageFormat.Png);
  return mstream;
}
Help

EDIT ow i think i see it now looking at MRsmiths example one mom
Witte is offline Reply With Quote
Reply

Bookmarks

Thread Tools
 
EntropiaTracker.com Global Trends
Hunting Globals: -22.19 % Mining Globals: -29.36 % Crafting Globals: + 5.04 %
EntropiaTracker.com Latest Uber Loots
 SPIRITS GOD whoemI HGW Gazzurdite stone - 1019 PED: 12/3/2008 06:53 | Sebastian CronZero Exargo Vivo T15 (L) - 31101 PED: 12/3/2008 05:13 | Amen Cool Breeze Blackheart Simple IV Conductors - 1038 PED: 12/3/2008 03:18 | Marcus Macce Vallteng Feffoid Raider - 1105 PED: 12/2/2008 23:52 | idvali idvali mosu OreAmp OA-101 (L) - 1588 PED: 12/2/2008 23:30 | Dinivan Dinni Almord EnMatAmp MA-107 (L) - 1545 PED: 12/2/2008 23:22 | Ezekial Zeke Sirrus Breer P1a (L) - 4212 PED: 12/2/2008 23:00 | Augis Auktuma Tumas Omegaton Flashfire - 40255 PED: 12/2/2008 22:42 | Zoot Equinox Vernal Caldorite stone - 1179 PED: 12/2/2008 22:32 | Frederic Zoligato Faure BodyGuard Shin Guards (F,L) - 1393 PED: 12/2/2008 22:29 | Walter Walter Himmel Crude Oil - 10062 PED: 12/2/2008 22:15 | Armak Mack Zardacon Breer P1a (L) - 1469 PED: 12/2/2008 21:25 | Bigfot Tomten Painkiller E-Amp 13 - 1183 PED: 12/2/2008 20:49 | JaponEs Japyx Mix Argonaut Guardian - 1068 PED: 12/2/2008 19:58 | Pereat AgnusDei Post Festum OreAmp OA-101 (L) - 3295 PED: 12/2/2008 19:56 | ENTROPIAS MOST WANTED OreAmp OA-101 (L) - 2493 PED: 12/2/2008 19:54 | TheMan Cooze18 TheBest Iron stone - 1577 PED: 12/2/2008 19:50 | Alex Neophyte Zane OreAmp OA-105 (L) - 1084 PED: 12/2/2008 19:43 | JaponEs Japyx Mix Argonaut Raider - 1073 PED: 12/2/2008 19:27 | Rangers: Fanor & 6y Atrox Old - 1503 PED: 12/2/2008 19:27 | Helmars Funbot 15th GeoTrek LP485 Apis (L) - 1363 PED: 12/2/2008 18:35 | Lili Bella Liliana Atrox Alpha - 2820 PED: 12/2/2008 18:28 | Cedric Dreicc Hafgolf Rage Pants (F,C) - 3380 PED: 12/2/2008 18:09 | Hank mchammer Hammer GeoTr