mcerk Posted December 27, 2005 Posted December 27, 2005 Hi. I'd like to manipulate with some image files with windows service application. If I start a windows project in Visual Studio, then Images and Bitmaps objects are not supported. Why? Why windows service shouldn't operate with System.Drawing classes??? Here are few sample fucntions, that doesn't work. Can U help me? Private Function Crop(ByVal img As Image, ByVal Img_X As Integer, ByVal Img_Y As Integer, ByVal Img_width As Integer, ByVal Img_height As Integer) As Image 'crop image Dim bmpImage As Bitmap = New Bitmap(img) Dim recCrop As Rectangle = New Rectangle(Img_X, Img_Y, Img_width, Img_height) Dim bmpCrop As Bitmap = New Bitmap(recCrop.Width, recCrop.Height, bmpImage.PixelFormat) Dim gphCrop As Graphics = Graphics.FromImage(bmpCrop) 'pustimo na vrhu plac za text Dim recDest As Rectangle = New Rectangle(0, 15, Img_width, Img_height + 15) gphCrop.Clear(Color.White) gphCrop.DrawImage(bmpImage, recDest, recCrop.X, recCrop.Y, recCrop.Width, recCrop.Height, GraphicsUnit.Pixel) Return bmpCrop End Function Private Function AddText(ByVal img As Image, ByVal Text As String) As Image 'add text Dim bmp As Bitmap = New Bitmap(img) Dim gphText As Graphics = Graphics.FromImage(bmp) Dim f As Font = New Font("Arial", 5, FontStyle.Italic) gphText.DrawString(Text, f, Brushes.Black, New Point(1, 1)) Return bmp End Function Private Function ResizeImage(ByVal img As Image, ByVal Img_Width As Integer, ByVal Img_Height As Integer) As Image 'resize Dim imgCallBack As System.Drawing.Image.GetThumbnailImageAbort = New System.Drawing.Image.GetThumbnailImageAbort(AddressOf CallBackMethod) Dim imgThumbnail As System.Drawing.Image = img.GetThumbnailImage(Img_Width, Img_Height, imgCallBack, IntPtr.Zero) Return imgThumbnail End Function Quote
Administrators PlausiblyDamp Posted December 27, 2005 Administrators Posted December 27, 2005 What do you mean by not supported? If you are getting errors about the System.Drawing namespace you simply need to add a reference to the System.Drawing.Dll. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.