Jump to content
  • Advertisement
Sign in to follow this  

[.net] Bitmaps and png images with ca 300 dpi

This topic is 5243 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I recently stumbled uppon an a strange behavior when trying to load png images in .net with bitmap(string) when the dpi of the image is ca 300. If you have the Nvidia sdk installed search for a file called : C:\Program Files\NVIDIA Corporation\SDK 9.0\MEDIA\textures\rectangles\nvlogo_rect.png Write a little program as this.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
    public partial class Form1 : Form
        public const string constImageFile = @"C:\Program Files\NVIDIA Corporation\SDK 9.0\MEDIA\textures\rectangles\nvlogo_rect.png";
        //public const string constImageFile = @"d:\temp\images\3dlabsnormal.png";
        //public const string constImageFile = @"d:\temp\images\winter.bmp";

        protected Bitmap pBitmap;

        public Form1()

        private void Form1_Load(object sender, EventArgs e)
            pBitmap = new Bitmap(constImageFile);

            this.Size = pBitmap.Size;

        protected override void OnPaint(PaintEventArgs e)
            if (pBitmap != null)
                e.Graphics.DrawImageUnscaled(pBitmap, 0, 0);

Notice that the bitmap reports correct width but when drawing it. It will be drawn as a thumb view in the upper left corner. Is there anything here that I've missed? Should have done otherwise? The error/mistake is also reproduced with the image 3dlabsnormal.png which comes with the 3dlabs sdk. Sorry for the bad english, it't not my native language. (Sorry for not showing a screenshot but I've no place to host it so.) EDIT: Switched to using e.Graphics instead of Form.CreateGraphics().

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!