The first thing that the program does is try to create a bitmap, but creating a bitmap of an .EFF file results in a null bitmap. That causes an exception further into the program but the root cause is a null bitmap!
newgraphics.Clear( Color.FromArgb( -1 ) ); if ( (float) oldbmp.Width / (float) newsize.Width == (float) oldbmp.Height / (float) newsize.Height ) //Target size has a 1:1 aspect ratio { newgraphics.DrawImage( oldbmp, 0, 0, newsize.Width, newsize.Height ); } else if ( (float) oldbmp.Width / (float) newsize.Width > (float) oldbmp.Height / (float) newsize.Height ) //There will be white space on the top and bottom {
newgraphics.DrawImage( oldbmp, 0f, (float) newbmp.Height / 2f - ( oldbmp.Height * ( (float) newbmp.Width / (float) oldbmp.Width ) ) / 2f, (float) newbmp.Width, oldbmp.Height * ( (float) newbmp.Width / (float) oldbmp.Width ) ); } else if ( (float) oldbmp.Width / (float) newsize.Width < (float) oldbmp.Height / (float) newsize.Height ) //There will be white space on the sides { newgraphics.DrawImage( oldbmp, (float) newbmp.Width / 2f - ( oldbmp.Width * ( (float) newbmp.Height / (float) oldbmp.Height ) ) / 2f, 0f, oldbmp.Width * ( (float) newbmp.Height / (float) oldbmp.Height ), (float) newbmp.Height ); } // Write new image to memory stream so it can be returned as byte[] MemoryStream stream = new MemoryStream(); newbmp.Save( stream, format ); return stream; } } }
eric2820
Contributor
2777 Points
1161 Posts
Need to resize eff files
Mar 26, 2012 10:09 AM|LINK
I have a new contract job and the company is using the .eff file format for some text that they want on their web page.
I imported a resize class that works with .jpg and .bmp files but fails to load .eff files.
I'm looking for how to modify the resize class to work with .eff files.
http://www.my-msi.net/Admin
blog
If a post helps you, please mark it as Ansered, thank-you.
Mamba Dai - ...
All-Star
23531 Points
2683 Posts
Microsoft
Re: Need to resize eff files
Mar 28, 2012 06:12 AM|LINK
Hi,
What error you got?
Feedback to us
Develop and promote your apps in Windows Store
eric2820
Contributor
2777 Points
1161 Posts
Re: Need to resize eff files
Mar 28, 2012 02:14 PM|LINK
The first thing that the program does is try to create a bitmap, but creating a bitmap of an .EFF file results in a null bitmap. That causes an exception further into the program but the root cause is a null bitmap!
http://www.my-msi.net/Admin
blog
If a post helps you, please mark it as Ansered, thank-you.
Mamba Dai - ...
All-Star
23531 Points
2683 Posts
Microsoft
Re: Need to resize eff files
Mar 29, 2012 07:00 AM|LINK
Could you share your source code creating a bitmap of an.EFF file?
Feedback to us
Develop and promote your apps in Windows Store
eric2820
Contributor
2777 Points
1161 Posts
Re: Need to resize eff files
Mar 29, 2012 11:07 AM|LINK
{
using ( Bitmap newbmp = new Bitmap( newsize.Width, newsize.Height ), oldbmp = Bitmap.FromStream( new MemoryStream( image ) ) as Bitmap )
{ using ( Graphics newgraphics = Graphics.FromImage( newbmp ) )
{
http://www.my-msi.net/Admin
blog
If a post helps you, please mark it as Ansered, thank-you.
Mamba Dai - ...
All-Star
23531 Points
2683 Posts
Microsoft
Re: Need to resize eff files
Mar 30, 2012 04:00 AM|LINK
You souce code is ok.
You said the BitMap you created from extension EFF file is null with this code:
Try another approach to create BitMap:
Not sure but try to test.
Make sure you can retrieve the File stream from .EFF file, and don't read it to byte array. Pass it as one parameter to BitMap constructure directly.
BTW, if it still doesn't wokr. Maybe the BitMap can't handle the .EFF file.
Feedback to us
Develop and promote your apps in Windows Store