I'm trying to rotate a System.Drawing. Icon, but first I need to convert it to a System.Drawing. Bitmap, then rotate it, and then convert it back to a System.Drawing. Icon, which is being looped, which works fine... for 2:34 minutes.
I'm using this to convert the System.Drawing. Icon to a System.Drawing. Bitmap -
public static System.Drawing.Bitmap ToBitmap(System.Drawing.Icon Icon)
-
{
-
System.IO.MemoryStream IconStream = new System.IO.MemoryStream();
-
Icon.Save(IconStream);
-
-
byte[] BitmapBytes = IconStream.ToArray();
-
-
System.IO.MemoryStream BitmapStream = new System.IO.MemoryStream(BitmapBytes, 0, BitmapBytes.Length);
-
BitmapStream.Write(BitmapBytes, 0, BitmapBytes.Length);
-
-
return new System.Drawing.Bitmap(System.Drawing.Bitmap.FromStream(BitmapStream));
-
}
-
The reason I'm doing this is because for some reason, Icon.ToBitmap() , turns all transparency to white, my method how ever does not.
But my method also causes an error after 2:34 minutes, which is on the return, which says, "Parameter is not valid."
And besides that, from what I'm aware, there's no other way of doing this, and this also causes another error after 2:34 minutes. -
public static System.Drawing.Icon ToIcon(System.Drawing.Bitmap Bitmap)
-
{
-
return System.Drawing.Icon.FromHandle(Bitmap.GetHicon());
-
}
-
After 2:34 minutes, I also get the error, "A generic error occurred in GDI+."
Most of the time the GDI+ error occurs, but sometimes the other one occurs, and I'm not sure what to do about this.
Any help would really be appreciated.
2 2228 http://www.dreamincode.net/forums/to...space-part-ii/ this has got everything and more that you could ever want to know about the system.drawing namespace, complete with demonstrations, for example here is the code used to rotate an image, it is different from yours and therefore may give you different results, (it still requires you to turn it into a bitmap and back but you seem to be fine with doing that.) let me know if this code works better for you! - public static Image RotateImage(Image img, float rotationAngle)
-
{
-
//create an empty Bitmap image
-
Bitmap bmp = new Bitmap(img.Width, img.Height);
-
//turn the Bitmap into a Graphics object
-
Graphics gfx = Graphics.FromImage(bmp);
-
//now we set the rotation point to the center of our image
-
gfx.TranslateTransform((float)bmp.Width / 2, (float)bmp.Height / 2);
-
//now rotate the image
-
gfx.RotateTransform(rotationAngle);
-
gfx.TranslateTransform(-(float)bmp.Width / 2, -(float)bmp.Height / 2);
-
//set the InterpolationMode to HighQualityBicubic so to ensure a high
-
//quality image once it is transformed to the specified size
-
gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
-
//now draw our new image onto the graphics object
-
gfx.DrawImage(img, new Point(0, 0));
-
//dispose of our Graphics object
-
gfx.Dispose();
-
//return the image
-
return bmp;
-
}
-
I should have mentioned that the code I'm using in to rotate the image between conversion is exactly that.
I'm having no problem converting the icon to a bitmap, rotating it 15 degrees, and then converting it back to an icon every 40 milliseconds for 2:34 minutes, but after that I get one of those two errors, which from the fact that I've rotated it many times during a time span of 2:34 minutes, I don't understand what is causing this error.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bartosz Majewski |
last post by:
Hello,
I have a question. Is there any possibility to compile MS Access database
(e.g. *.mdb file) to standalone, executable application? I'd like to use
such database application on a computer where Access is not installed. I
know, that it's possible to write such kind of app in Visual Basic, but as
far as I know, there cannot be any relations in that program (and that is
why that solution is not, what I mean). I would be greateful for...
|
by: Jos De Laender |
last post by:
Following simple program :
#include <stdio.h>
char *Convert(int Arg) {
static char Buffer;
printf("Convert called for %d\n",Arg);
sprintf(Buffer,"%d",Arg);
printf("Convert about returning %s\n",Buffer);
return Buffer;
|
by: Andreas Klemt |
last post by:
Hello,
I have this
session("myNumber") = 888
Dim intNumber As Integer
a) intNumber = session("myNumber")
b) intNumber = Convert.ToInt32(session("myNumber"))
|
by: Alex Nitulescu |
last post by:
Hi. I have created a web-based "file manager", for remote-administration of
a web-site. It works okay.
The "main" form in the "file manager" is BrowseFiles.aspx. I can edit the
text files (among which the "js" files) by clicking on an achor which
redirects me to "edit.aspx".
Once in "edit.aspx", after I view a ".js" file, for instance, I click on the
button "Return to file manager". The code in the command "Return to file
manager" is...
|
by: byrd48 |
last post by:
Hi,
I am developing a web site which allows users to upload and share
photos. I have a datalist which lists the photos and has the usual
edit, update commands.
Within the edititemtemplate, I have links to allow the user to rotate
the photo 90 degrees left or right. After I rebind the datalist,the
photo is not rotated on the web page, although it correctly rotated on
the server. If I click refresh, it updates, but calling refresh causes...
| |
by: Mike Collins |
last post by:
This worked in the command window while in debug mode
?table.Rows.ItemArray.ToString()
"f0165f94-648f-4997-b578-11d89c8b1f61"
But gives the error below when I compile.
Cannot implicitly convert type 'string' to 'int' and the word ColumnName is
underlined.
|
by: WT |
last post by:
Hello,
VS2005 with SP1.
I succefully coverted my Web Site Project to Web Application project, but,
for an aspx class, the manuel (by right clic menu) 'Covert to Web
Application, gives the error.
'Could not parse the file app_support\myfile.aspx'
and no designer.cs file is created. It is working for all other aspx files
in this app_support folder ?
|
by: IanJSparks |
last post by:
I've been doing some image rotation with PIL and comparing the images
with imagemagick's convert -rotate output.
Imagemagick uses an RBS / Paeth rotation algorithm that appears to
give better results than PIL's rotate method.
However, I love PIL and don't want to have to shell out to imagemagick
or use it's python bindings if I can stay with my beloved Python
Imaging Library.
|
by: kronus |
last post by:
Hi everyone,
Please tell me what I am doing wrong:
I have an xml data coming to my Air application that looks something like this:
<project name="Sales Demos" path="/Company Home/Client Spaces/Sales Demos" type="{http://www.myCo.org/model/content/1.0}folder" id="71f36dcd-b59b-11dd-8205-5992b4466fe5" modified="Nov 18, 2008 3:51:20 PM" size="" icon32="/images/icons/default.gif" viewurl=""/>
<project name="Something else" ...
etc...
/>
|
by: furqi |
last post by:
hi every body
i write a code in c sharp in which i have made a base class and make an event there.Then i make a derived class and made an other event in that class.
Now what i wanna do is that i wanna invoke in derived class method the base class event but i am facing an error there i am unable find the solution.canaby body tell me the solution.following is the code.
using System;
using System.Collections.Generic;
using System.Linq;...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| | |