Windows service and Bitmap, Image ... etc objects

mcerk

Regular
Joined
Nov 1, 2004
Messages
78
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?

Visual Basic:
    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
 
Back
Top