473,385 Members | 2,013 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,385 software developers and data experts.

Graphics.DrawImage upside down? (rotate 180 degrees)

Hey All,

Is it possible to draw an image upside down?

I am using Microsofts example of "Printing a local report without
preview".

The only trick is that I want to flip the image upside down.

Reason: I need to guarantee that I print a barcode in the exact same
location (lower right side) no matter the paper size. So if I flip the
image upside down (rotate 180) then the upper left corner will be my
fixed point.

Thoughts?

~Gina_M~

Jul 25 '07 #1
5 6907
On Tue, 24 Jul 2007 17:37:48 -0700, Gina_Marano <gi*******@gmail.com>
wrote:
Hey All,

Is it possible to draw an image upside down?
You may want to look at the Graphics.Transform property. You could create
a transformation matrix that supplies the appropriate rotation, as well as
moving the origin to the opposite corner of the page. Then everything you
draw would as if you had just rotated the whole page 180 degrees.

Of course, do this only with those things you want to be rotated.
Otherwise, you might as well just physically rotate the paper when it's
finished printing. :)

All that said:
[...]
The only trick is that I want to flip the image upside down.

Reason: I need to guarantee that I print a barcode in the exact same
location (lower right side) no matter the paper size. So if I flip the
image upside down (rotate 180) then the upper left corner will be my
fixed point.
IMHO, if all you care about is the _position_ of the barcode, then
flipping it upside down is way more effort than you need to make. It's
trivial to find the lower right corner, and then create your drawing
rectangle based on that and the actual size of your bitmap, and doesn't
require any fiddling around with the transformation for the Graphics
instance.

Pete
Jul 25 '07 #2
Gina_Marano wrote:
Hey All,

Is it possible to draw an image upside down?

I am using Microsofts example of "Printing a local report without
preview".

The only trick is that I want to flip the image upside down.

Reason: I need to guarantee that I print a barcode in the exact same
location (lower right side) no matter the paper size. So if I flip the
image upside down (rotate 180) then the upper left corner will be my
fixed point.

Thoughts?

~Gina_M~
FYI: A flip will not produce the same results as a 180 degree rotation.
It sounds like you want to make sure the bar code can be scanned from
the top left no matter which way up the paper is. If so then a 180
degree rotation will be the way to go as a flip will have the bar code
back to front.

It's a small difference but will make a large difference to your bar
code scanner.
Jul 25 '07 #3
FYI: A flip will not produce the same results as a 180 degree rotation.
It sounds like you want to make sure the bar code can be scanned from
the top left no matter which way up the paper is. If so then a 180
degree rotation will be the way to go as a flip will have the bar code
back to front.

It's a small difference but will make a large difference to your bar
code scanner.- Hide quoted text -

- Show quoted text -
Yes, rotating 180 degrees is what I meant. How would one do this?

Pete, the reason for the rotate is so I don't have to care about the
page length and width. I probably don't want to have to query the
printer to try and find out what size of paper is in tray 1... All I
care about is that the position of the barcode is in the same position
lower right hand corner of the paper regardless of papersize. Note: if
it where just the length that varies then I would just have to use a
report footer but after getting that working I realized that the width
could vary also.

Any ideas how one would rotate the image 180 degrees?

~Gina_M~

Jul 25 '07 #4
On Wed, 25 Jul 2007 06:33:47 -0700, Gina_Marano <gi*******@gmail.com>
wrote:
Pete, the reason for the rotate is so I don't have to care about the
page length and width. I probably don't want to have to query the
printer to try and find out what size of paper is in tray 1
You get the page size in the PrintPageEventArgs. There's no need to
"query the printer".
... All I
care about is that the position of the barcode is in the same position
lower right hand corner of the paper regardless of papersize.
Then look at the paper size in the PrintPageEventArgs and position the
barcode according to the paper size. It's no different than, for example,
drawing a footer on a printed page or anchoring a user-interface element
to the right and/or bottom of a window.
Note: if
it where just the length that varies then I would just have to use a
report footer but after getting that working I realized that the width
could vary also.
I don't know what a "report footer" is, but if you have that as an option,
why doesn't the "report footer" offer support for specifying alignment?
As in, make the element you want to include in the footer right-aligned,
so that it always winds up flush against the right side of the footer?
Any ideas how one would rotate the image 180 degrees?
Yes. I posted that information in my first reply. There are other ways,
but what I already wrote is the most straightforward, IMHO.

Pete
Jul 25 '07 #5
You get the page size in the PrintPageEventArgs. There's no need to
"query the printer".
Ahh, this is great!
Then look at the paper size in the PrintPageEventArgs and position the
barcode according to the paper size. It's no different than, for example,
drawing a footer on a printed page or anchoring a user-interface element
to the right and/or bottom of a window.
Great!
I don't know what a "report footer" is, but if you have that as an option,
why doesn't the "report footer" offer support for specifying alignment?
As in, make the element you want to include in the footer right-aligned,
so that it always winds up flush against the right side of the footer?
That would be nice but I have used many report builders and none that
I know of allow that. :(
Yes. I posted that information in my first reply. There are other ways,
but what I already wrote is the most straightforward, IMHO.
Yes, I figured it out. I was rendering to EMF then trying to rotate.
WRONG!! Much easier to render to BMP then simple rotate. :) As I have
said often, I make things too hard sometimes.

Thanks for your help! I will go through it and probably post a follow
up. I am having problems just printing a normal report as landscape.
More details soon.

~Gina_M~

Aug 3 '07 #6

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

Similar topics

0
by: Otie | last post by:
I have a circle that displays information in 1-degree increments - there are 90 such increments that comprise the circle. I need a pointer within the circle that rotates. The pointer must include...
8
by: Mark Johnson | last post by:
Using: VS 2003 NET C# for Framework and Framework Compact Trying : Moving a Card (Bitmap) as in Solitare (PC + WinCe) Version on OnMouseMove Problem : The affected drawing Area by Invalidate (or...
3
by: Peter Oliphant | last post by:
I'm importing a jpeg via: Bitmap* image = new Bitmap( filename ) ; Then, using the Drawing::Graphics object, I execute DrawImage( image, x, y ). My problem is that the original image was...
8
by: Nathan Sokalski | last post by:
I am trying to write code to rotate a graphic that I have. Here is the code I am currently using: Dim frogbitmap As New Bitmap(Drawing.Image.FromFile(Server.MapPath("images/frog.gif"))) Dim...
0
by: Kwok | last post by:
Using html, I want to rotate the word upside down. When a user input a sentence, the sentence then will rotate 180degree. I use <div>, it can only rotate 90degree..... can anyone help me??
8
by: lovecreatesbeauty | last post by:
I write a function to rotate a matrix by 90 degrees clockwise, this function works on a matrix of specific size, for example, it rotates a 4*4 matrix of integers in the following code. The function...
1
by: RC | last post by:
First, this is a SVG issue, not 100% of XML issue. But I can't find SVG group to post this. Since SVG is XML file, I post here hopefully someone know both SVG and XML can help. Here is my SVG...
2
by: drsmooth | last post by:
Hi, i have made several different things using a double buffer and a jframe before but never had this problem: if you look thrugh the code, you can see that i draw a whole bunch of stuff to the...
0
by: harryusa | last post by:
I am experimenting with the rotate function and so far I can't get my code to return anything but the URL of my script. Here it is: <?php // The file you are rotating $image =...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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.