473,412 Members | 1,921 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,412 software developers and data experts.

The picture loses of its color depth/ quality when loaded to the picturebox

Hi, when I use the following code:

Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
pictureBox1.DrawToBitmap(bmp, new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height));
this.ClearPic();
this.pictureBox1.Image = bmp;

it seems like the quality of the picrture degrades and it loses of its color depth - why? How can I fix it?

Thanks
Jul 23 '08 #1
7 1776
Plater
7,872 Expert 4TB
When you created your bitmap, it does not look like you specified the pixel depth(and etc), maybe you need to do that?
Jul 23 '08 #2
The picture drawn to the bitmap is some drawn lines - I have an Arraylist of points and it draws lines - Actually my target is to rotate that image - those drawn lines but I don't know how. So what I have done is created a bitmap of the picturebox "image" (i.e what's shown there - the Image property is actually null...) , reloaded that to the picBox.Image and then rotated it - but it loses its quality - I don't have any idea why - I am pretty new to c# graphics and don't know how to use pixels and so on...

I need a code sample for rotating the drawnlines with a matrix or somehing without creating that bitmap and loading it to the picbox Image , or an explanation and a solution as well to how make it save the quality of the loaded pic.

I prefer to rotate that using some code you know - but I don't know how to do that.

Please help me somehow.

Thanks.
Jul 23 '08 #3
Plater
7,872 Expert 4TB
Hmm is your picturebox square? Because if not, you could see some wierd stretching behavior
Jul 23 '08 #4
Oh man you're great!! that was it!! As you said I set the size - 400x400 and now it works fine!!

Thanks.

Now please if you can just answer my second question:

If I want to rotate the pic at a specific angle - say 50 degrees - there is no method such as rotate(50)... How can I accomplish that?

Thanks!!
Jul 23 '08 #5
Plater
7,872 Expert 4TB
Uhh I think you're going to need to do some serious math on that.
I think you need to take the formula for an elipse and find tangent points for every pixel in your picture, using the center of the picture as the center of your elipse, and then find the tangent point say 50degrees away from the first tangent point?
I've never really tried so I dunno.
Jul 23 '08 #6
Do you mean the trigo function - tan? How??! Oh my god!

And what about the elipse? Where did it come from and what's the connection?

Ouch that's a little difficult!
Jul 23 '08 #7
Plater
7,872 Expert 4TB
Well I said elipse because it's possible that the picture you wish to rotate is not a square. You need your bounding rectangle to be inscribed inside an elipse I think
Jul 24 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Bill N. | last post by:
Using VB .Net 2003 Standard Edition. This simple form has a "File in Use" problem while the executable is running. Created this simple program to make sure that I hadn't done something in my...
2
by: Michael Lehar | last post by:
Hallo I have a pictureBox with a picture loaded from file, then I draw some lines on the picture, and then I want to save the new picture. Befor I can draw lines I have to create a Graphics...
1
by: Fredrik Melin | last post by:
Hi, If I do a copy of a jpg picture to the clipboard. Then I do PictureBox1.Image = CType(IData.GetData(DataFormats.Bitmap), Bitmap) Then I save the Picture from the picturebox as jpeg. ...
6
by: Michael | last post by:
I'm trying to use the Bitmap class's Save Method to save a Bitmap as a GIF. My code runs fine, and converts the image, but the quality is not anywhere close to as good. I know that GIF quality is...
3
by: Rado | last post by:
Hello. In picturebox I have loaded some picture picturebox.image.fromfile(......) It's ok. But Have can I cancel Image from picturebox. Thanks.
4
by: Charles | last post by:
Hello Everyone, I have been gettting great feedback from microsoft.public.vc.language group but after doing more searching I think my post should be directed to this group. I am trying to make...
2
by: blazingmavrick | last post by:
Hi My problem consits of the following:- i am creating mulitple picturebox's, when the user double clicks on the picture box it opens the opendialog box to load a picture (jpeg only) into the...
1
by: blazingmavrick | last post by:
My problem consits of the following:- i am creating mulitple picturebox's, when the user double clicks on the picture box it opens the opendialog box to load a picture (jpeg only) into the picture...
1
by: =?Utf-8?B?UEsgRmVycmljaw==?= | last post by:
Hi all, My first post to MSDN... I've recently started to get into VB.NET, having been a casual VB user for a few years. So far, it's going OK. I've managed to figure out how to draw lines on...
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
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
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
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...
0
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,...
0
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...

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.