GDI+Desktop graphics and printing library

Discussion in 'Additional Libraries' started by agraham, Dec 27, 2008.

  1. agraham

    agraham Expert Licensed User

    This major new desktop and .NET 2.0 only library is upwardly compatible with ImageLibEx and adds a load of additional graphics functionality that only exists on the desktop GDI+ graphics system. It also fully supports printing, including page setup and print preview, so that anything you can draw on an image can also be printed.

    To a certain extent you are on your own using this library, I can document the functionality but I can't teach you how to use it. If you can use ImageLib or ImageLibEx you can easily get the same things printed and the additional graphics capabilities are pretty straightforward to use.. However to use some of the more advanced MeasureString and DrawString methods to format text will need some trial and error (probably lots of error!) and/or some research on the Web. To ease the problem of text formatting I have copied over the Rich Text Format printing support from my RichTextDesktop library, and improved it so that Rich Text can now be rendered on an image as well as being printed.

    The output of the demo app included is a bit bit scrappy. As I have stated before I am not a "graphics" person and unlike some people I know who get a buzz out of writing graphics code I get bored doing it - my forte is the abstract stuff. Please therefore look past what the output looks like and examine what the library can do and how it does it.

    It is probably as well to regard this first release as somewhat of a beta version as, due to the extent of the functionality of the thing, I have not been able (or willing!) to try many things in combination so I'm sure there will be some bugs and lots of errors in the help (I got really bored writing the help :().

    EDIT :- Version1.1 posted with minor tweak to BitmapEx.Zoom memory management and BitmapEx.Zoom documented in the help.

    EDIT : - Version 1.2 with some additional functions to match ImageLibEx improvements. See post #3 for details.

    EDIT : - Version 1.3 allows some page settings to be changed for an individual page during the printing process. See post #8 for details.

    EDIT : - Version 1.4 posted to match the changes in ImageLibEx 2.0. See post #10 for details.
     

    Attached Files:

    Last edited: Jan 21, 2010
  2. agraham

    agraham Expert Licensed User

    Version 1.1 now posted with a very minor tweak to BitmapEx.Zoom memory management to dispose of an internal Bitmap object rather than rely upon the .NET garbage collector.

    BitmapEx.Zoom is now documented in the help. It existed previously but I missed including it in the help.
     
    Last edited: Jan 7, 2009
  3. agraham

    agraham Expert Licensed User

    Version 1.2 has the three improvements requested by Klaus for ImageLibEx.

    FloodFill.Flood overwrites everything until a specified boundary color is found.

    DrawerEX.DrawCircle draws a circle.

    DrawerEX.FillCircle draws a filled circle.

    Also added are DrawerEx.ARGB() and DrawerEx.GetARGB. These are similar to Basic4ppc RGB() and GetRGB() but include the alpha component of a desktop color.
     
  4. corwin42

    corwin42 Expert Licensed User

    Hello Andrew,

    I use your GDI+ Library to print some pages. I need to set the left and right margin individual for each page (left pages have another margin than right pages).

    In the help file under the printer object section there is an Event QueryPageSettings explained.

    I don't understand this completely. As I understand this, in this event call I should be able to set the margin for my page. I just tried to set printer.LeftMargin to another value but this does not work.

    Can you explain it in more detail or do you have an example for this?

    I think I have to use the door.library to obtain the QueryPageSettingsEventArgs.PageSettings property?

    Thanks,
    Markus
     
  5. agraham

    agraham Expert Licensed User

    Try this and post the results. There are 6 new properties

    Cancel - stops printing when set in the event Sub for any of the events.

    The following are page settings that may be read/written within the PrintPageEvent or QueryPageEvent. It is not clear from the .NET documentation whether modifying these settings has different effects in the two events or not.

    PsLandscape
    PsLeftMargin
    PsRightMargin
    PsTopMargin
    PsBotttomMargin
     

    Attached Files:

  6. corwin42

    corwin42 Expert Licensed User

    Works perfectly.

    If you change these properties in the QueryPageSettings event then you get the correct margin sizes in the PrintPage event with printer.Marginbounds.

    Changing the properties in PrintPage doesn't seem to work.

    Thanks very much.
     
    Last edited: Jan 5, 2010
  7. corwin42

    corwin42 Expert Licensed User

    Hi Andrew,

    if you make a new release (with .cs file) of this version, I will share my little Application. I think its a good example of what can be done with Basic4PPC in really short time. :sign0060:

    Thanks very much again for your extremely fast support.
     
  8. agraham

    agraham Expert Licensed User

    Version 1.3 posted with the changes referred to in post #5 above incoporated into the source and help files.
     
  9. corwin42

    corwin42 Expert Licensed User

    Weekly Calendar example

    Ok, here is a more complex example of what can be done with this library. This program was hacked together in just one day. I think this shows the power of Basic4PPC and its additional libraries.

    Needs Version 1.3 or above of GDI+Desktop Library

    The program just creates a weekly calendar (dates are configurable) that you can print out. Have fun with it.
     

    Attached Files:

  10. agraham

    agraham Expert Licensed User

    Version 1.4 was posted to incorporate the same functionality as ImageLibEx 2.0.

    BitmapEx now has all the functionality of ImageLibEx.BitmapEx and an Icon class similar to ImageLibEx.Icon is added.
     
  11. berndgoedecke

    berndgoedecke Active Member Licensed User

    Error cs1525 during compilation

    Hello AGraham,
    I use GDI Desktop to save a Bitmap to a File like this:
    BMapExCop.SaveImage(AppPath & "\Temp\Blob.jpg")
    It works in the Editor even if the GDI Desktop Help references another syntax like this:
    BMapExCop.SaveImage(PathName As String, Channel As String, Format As String)
    During compilation I get the cs1525 error.
    What is wrong?

    Best regards

    berndgoedecke
     

    Attached Files:

  12. agraham

    agraham Expert Licensed User

    There's nothing wrong. The method call should have a format parameter. The IDE isn't strict enough in its' checking, it really should give you an error. You don't get an error from the library because it defaults to JPG if it doesn't understand the format string, or lack of, given to it.
     
  13. berndgoedecke

    berndgoedecke Active Member Licensed User

    BitBlit

    Hello AGraham,
    i've tried some kind of Syntax in the BitBlit-command:

    BMapExCopM.Value = BMapExCopM.BitBlt(BMapExCop.Value, StrRec.Value, 0, 0, D=D<S )

    or

    BMapExCopM.Value = BMapExCop.BitBlt(BMapExCop.Value, StrRec.Value, 0, 0, D=D<S )

    or

    SRCCOPY = 13369376 '(&HCC0020)
    BMapExCopM.Value = BMapExCopM.BitBlt(BMapExCop.Value, StrRec.Value, 0, 0, SRCCOPY)

    or

    SRCCOPY = 13369376 '(&HCC0020)
    BMapExCopM.Value = BMapExCop.BitBlt(BMapExCop.Value, StrRec.Value, 0, 0, SRCCOPY)

    but always appears the error "Raster op is not valid".
    How this function operates?

    Best regards

    berndgoedecke
     
  14. agraham

    agraham Expert Licensed User

    From the help

    BitBlit(src As Image, srcrect As Rectangle, destleft As Int32, desttop As Int32, rasterop As String )

    Also there is no return value from BitBlit

    "The existing internal bitmap is modified."

    try

    BMapExCopM.BitBlt(BMapExCop.Value, StrRec.Value, 0, 0, "D=D<S")
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice