473,809 Members | 2,780 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bitmap and Graphics

Hi,

I'm trying to blit small bitmaps onto a larger bitmap, and I've got a
few issues wrt positioning and output size.
I think my problems are due to DPI differences...
My small images are 72 DPI
My Large image (which i need to create in code) needs to be 300 DPI.

My code as it stands (with no accounting for dpi) is:

Bitmap bmp = new Bitmap(600, 600);
Graphics gfx = Graphics.FromIm age(bmp);
Bitmap bmpTemp = new Bitmap(strPath) ;
gfx.DrawImage(b mpTemp, 0, 0);
pictureBox1.Ima ge = bmp;
That works, but if i add the line:
bmp.SetResoluti on(300, 300);

the displayed image becomes massive. Is this because setting the
picturebox's image property with a bitmap object, does not take dpi into
account? If so, (or otherwise) how do i get the image to display correctly?

Also, the coordinates at which I place smaller image within the larger,
do not appear to take dpi into account. What adjustment do i need to
perform to place things in the correct place?
For example, If i place a 60x60 image at 0,0; and another 60x60 image at
60,60; the second overlaps the first :(

How do i correct this?

Thanks

Andrew
Jun 4 '06 #1
4 13301
"Andrew" <in********@THI Smuonlab.com> wrote in message
news:8J******** ********@newsfe 3-gui.ntli.net...

Can't you just do?:

gfx.DrawImage(b mpTemp, 0, 0, 600, 600);

Michael
Jun 4 '06 #2
Michael C wrote:
"Andrew" <in********@THI Smuonlab.com> wrote in message
news:8J******** ********@newsfe 3-gui.ntli.net...

Can't you just do?:

gfx.DrawImage(b mpTemp, 0, 0, 600, 600);

Michael

erm.... What for?
I get a similar problem when using a printing document in 1200 dpi.

I try to draw my image on it and it comes up some random size :s
Andrew
Jun 4 '06 #3
"Andrew" <in********@THI Smuonlab.com> wrote in message
news:cj******** *******@newsfe3-gui.ntli.net...
erm.... What for?


To specify the width and height of what it should draw.

Michael
Jun 4 '06 #4
Andrew wrote:
Hi,

I'm trying to blit small bitmaps onto a larger bitmap, and I've got a
few issues wrt positioning and output size.
I think my problems are due to DPI differences...
My small images are 72 DPI
My Large image (which i need to create in code) needs to be 300 DPI.

My code as it stands (with no accounting for dpi) is:

Bitmap bmp = new Bitmap(600, 600);
Graphics gfx = Graphics.FromIm age(bmp);
Bitmap bmpTemp = new Bitmap(strPath) ;
gfx.DrawImage(b mpTemp, 0, 0);
pictureBox1.Ima ge = bmp;
That works, but if i add the line:
bmp.SetResoluti on(300, 300);

the displayed image becomes massive. Is this because setting the
picturebox's image property with a bitmap object, does not take dpi into
account? If so, (or otherwise) how do i get the image to display correctly?

Also, the coordinates at which I place smaller image within the larger,
do not appear to take dpi into account. What adjustment do i need to
perform to place things in the correct place?
For example, If i place a 60x60 image at 0,0; and another 60x60 image at
60,60; the second overlaps the first :(

How do i correct this?

Thanks

Andrew


Call Bitmap.SetResol ution on each of your images so that the resolution
is the same for each if this is the effect you desire.

What is happening is that when you draw the 72dpi image onto the 300dpi
image it is scaling it to the same resolution ie 60px gets scaled to
250px to cater for the conversion from 72 to 300 dpi.

The "default" dpi for images also appears to be 96 in vs .net2.0.

JB
Jun 5 '06 #5

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

Similar topics

12
2389
by: Sanjay | last post by:
hi, We are currently porting our project from VB6 to VB .NET. Earlier we used to make scale transformations on objects like pictureBox , forms etc.Now Such transformations are made on the graphics object of the form/pictureBox. Should It be better if make a graphics object from my pictureBox in load event handler of the form and store it as member variable of the form , make
2
2181
by: TCR | last post by:
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...
4
2454
by: Renato Vieira | last post by:
In order to do some UI animation or drawings can I use a Graphics object in a WEB Forms project (in VisualStudio.NET) -- Renato /*Portugal*/ Vieira
3
26593
by: Mathieu | last post by:
Hi ! How may I concert Graphics to Bitmap or Save Graphics to file... // Dim g as Graphics // g = pictureBox1.CreateGraphics // g.Save ???? I Just want to Save g (Graphics) in file C:\g.bmp
7
2027
by: Dennis | last post by:
I am trying to implement drawing on a bitmap and using bitblt to transfer it to the control graphics object in the paint event. It seems to draw on the bitmap ok but doesn't get transferred to the control graphics object in the paint event. Any help would be appreciated. Here is my code: public class as mycontrol Private Declare Auto Function BitBlt Lib "GDI32.DLL" (ByVal hdcDest As IntPtr, ByVal nxDest As Integer, ByVal nyDest As...
1
1708
by: DSchlichte | last post by:
Hello ' I need some help. I've created a little application to paint, save and load pictures (Bitmap-graphics) into ' a picturebox-object on the desktop. There's no problem to paint or to load pictures, but how can I save the image? ' My load-routine is the following (if I click on the file-menu and chose File open...):
1
3646
by: placid | last post by:
Hi all, This is the following code i have, Public Class Form1 Inherits System.Windows.Forms.Form Dim A, B, c, U, x, y As Double Dim Red, Green, Blue As Integer
12
4049
by: Lee | last post by:
I have the following code using System; using System.Windows.Forms; using System.Drawing; using System.Collections; namespace FINN {
3
1734
by: Mathias | last post by:
I have the following code that generates a bitmap on which I'm drawing a graph. The graph has one point for each minute in a day so the bitmap is 1440 pixels in height. Therefore I'd like to place the bitmap in a scrollable control. I tried with a panel Panel panel = new Panel(); panel.Controls.Add(bitmap); but it doesn't work. So, can anyone tell me how to do it or point me in the right direction? Thanks :)
1
5603
by: martinsmith160 | last post by:
Hi all I am trying to create a level builder tool for a final year project and im having some problems drawing. I have placed a picture box within a panel so i can scroll around the image which is working fine. My aim is to double click the picture box and the desired image will be drawn at the mouse position. This works fine unless I scroll or minimise the form because the image isnt repainted after movement. I looked up drawing the image to...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.