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 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
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
"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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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...
|
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
|
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
|
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...
| |
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...):
|
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
|
by: Lee |
last post by:
I have the following code
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;
namespace FINN
{
|
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 :)
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |