473,386 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Is this a known bug with the Bitmap class??

TCR
Hi,
I posted this earlier and got a suggestion that didn't pan out. I am
trying to determine if there is a known bug related to the resolution value
returned when opening a .jpg file by passing the file path to the bitmap
class constructor or by using the Image.FromImage() static function to
return a bitmap object. I have tried to open a jpeg file to convert its
resolution to a lower value but it doesn't return the proper resolution
value when loading the initial image.. I know the images are 300 X 300 dpi
but it reports them as 72 X 72 dpi.
Thanks,
TCR
Nov 16 '05 #1
2 2154
"TCR" <th**********@verizon.net> wrote in
news:Pv*******************@nwrdny01.gnilink.net:
Hi,
I posted this earlier and got a suggestion that didn't pan
out. I am
trying to determine if there is a known bug related to the
resolution value returned when opening a .jpg file by passing
the file path to the bitmap class constructor or by using the
Image.FromImage() static function to return a bitmap object. I
have tried to open a jpeg file to convert its resolution to a
lower value but it doesn't return the proper resolution value
when loading the initial image.. I know the images are 300 X
300 dpi but it reports them as 72 X 72 dpi.


Troy,

The code below works for me. Note that if the image file doesn't
contain any resolution data, then the resolution of the
Bitmap/Graphics image defaults to the resolution of the video screen
(per Charles Petzold in "Programming Windows with C#").

You may want to ask this question again in the
microsoft.public.dotnet.framework.drawing group. There may be some
dotnet image experts there who don't frequent this group.

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/

---------------------------------------------------

using System;
using System.Drawing;

namespace Example
{
public class ExampleClass
{
public static int Main(string[] args)
{
// An image known to have 96 dpi.
string imagePath = @"C:\A_96_dpi_image.jpg";
///////////
// Bitmap
///////////

using (Bitmap b = new Bitmap(imagePath))
{
Console.WriteLine("Bitmap b:");
Console.WriteLine(" b.HorizontalResolution = {0}",
b.HorizontalResolution);
Console.WriteLine(" b.VerticalResolution = {0}",
b.VerticalResolution);
Console.WriteLine("");
}
///////////
// Image and Graphics
///////////

Image i = Image.FromFile(imagePath);

using (Graphics g = Graphics.FromImage(i))
{
Console.WriteLine("Graphics g:");
Console.WriteLine(" g.DpiX = {0}", g.DpiX);
Console.WriteLine(" g.DpiY = {0}", g.DpiY);
}

return 0;
}
}
}
Nov 16 '05 #2
I can confirm this because I once had the same problem that sometimes Jpeg
images seems to return the wrong resolution. I will send you my solution
this evening because I have it at home.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
"TCR" <th**********@verizon.net> schrieb im Newsbeitrag
news:Pv*******************@nwrdny01.gnilink.net...
Hi,
I posted this earlier and got a suggestion that didn't pan out. I am
trying to determine if there is a known bug related to the resolution value returned when opening a .jpg file by passing the file path to the bitmap
class constructor or by using the Image.FromImage() static function to
return a bitmap object. I have tried to open a jpeg file to convert its
resolution to a lower value but it doesn't return the proper resolution
value when loading the initial image.. I know the images are 300 X 300 dpi but it reports them as 72 X 72 dpi.
Thanks,
TCR

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: active | last post by:
This is what I do in a PictureBox New: b1 = New Drawing.Bitmap(Width, Height, Me.CreateGraphics()) g1 = Graphics.FromImage(b1) Someplace I do g1.DrawString.........
7
by: chuck | last post by:
I load a bitmap using GDI+ now, I want to collect all the pixel values, (in RGB but without the A component) onto a color array, say... dim btmp1(,) as color is there a method that can help me...
7
by: Fir5tSight | last post by:
Hi All, I used the following code in C#: using System.Drawing; //blah blah blah Bitmap bmp = new Bitmap();
1
by: Smokey Grindel | last post by:
I have a bitmap object I want to return as a JPEG image with a compression set at 90% and progressive passes enabled, how can I do this in .NET 2.0? Progressive passes are not necessary but the...
4
by: Jon Slaughter | last post by:
Whats is there any reason to use a Bitmap(Image) over an Image(Bitmap)? I'm making a container to hold bitmaps sorta like the ImageList class(that doesn't fix the sizes) but I'm not sure if I...
0
by: benfly08 | last post by:
Hi, guys. I have a program to draw bar/pie chart based on the data i hard coded in it. However, my image comes with "BLACK" background color. I don't know how to fix this. The code snippet is...
9
by: poifull | last post by:
Hi All, I have the following task: 1. create an image object in memory (a rectangle with nothing on it) 2. write some text on the rectangle 3. rotate the image 90 degree 4. save the image to a...
2
by: Peter Oliphant | last post by:
I want to create a new Bitmap which is a portion of an existing Bitmap. For example, if I have a Bitmap that is 100x100 in size I might want to create a new Bitmap that is equivalent to the one...
2
by: raylopez99 | last post by:
Beware newbies: I spent a day before I figured this out: copying a bitmap (image) file to file is not quite like copying a text file--you have to do some tricks (see below), like using a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.