Jump to content
Xtreme .Net Talk

Windows service and Bitmap, Image ... etc objects


Recommended Posts

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...