Results 1 to 40 of 110

Thread: [VB6] GDI+ Usage & Samples

Threaded View

  1. #1

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    [VB6] GDI+ Usage & Samples

    This project is a teaser to get one's feet wet. For a fully functional usercontrol that is based almost entirely on GDI+, see my alpha image control project.

    If you have questions on how to do something with GDI+ that the attached project does not do, please post your question in the Graphics portion of the forum. I do not want, nor intend that this posting become a proxy "GDI+ Forum"

    If you have questions about this project then by all means ask away. There may be a few logic errors in the project; as we find those I'll continue to update. Jump to bottom to determine when last updated.

    GDI+ is a very handy tool and many coders stay away from it because it appears difficult, at first. So, the classes in this project are aimed at easing you along a bit. GDI+ has 100's of functions and the project herein only touches a small percentage of them. But should be enough for you to get your feet wet without being overwhelmed.

    A great site for descriptions of the GDI+ API functions.

    I do plan on updating this project from time to time. Things I have knowledge on and have not yet added to the project include GDI+ paths, strings, and regions. The project does include a very complete image processing class, a rendering class, and a pens/brushes class to get you started.

    If you want the absolute minimal code to read and display an image at actual size, see post #8 below

    Name:  ScreenShot.PNG
Views: 27838
Size:  84.4 KB

    Some advantages of using GDI+
    :: Load/Save PNGs and TIFFs, even multi-page TIFFs
    :: Load and display animated GIFs
    :: Alphablending - images, lines, shapes, everything. GDI+ does not use standard RGB colors. All colors are ARGB which includes level of alphablending.
    :: Built-in niffty options like rotation, mirroring, on-the-fly pixel transformations and more
    :: No manual premultiplication of alpha values
    Some disadvantages of GDI+
    :: Crashes easy if not used properly. Objects created around other objects (i.e., images) are not actually stand-alone. GDI+ requires the source data to remain present until the GDI+ object is destroyed.
    -- Here is the MS KB Article link: http://support.microsoft.com/kb/814675
    -- The workaround is to create a DIBSection, then create a GDI+ bitmap from it and destroy the DIBSection
    -- But that workaround won't allow access to other images in a multi-image formats (GIFs, TIFFs) and 32bpp become pARGB.
    :: In IDE, can crash easily too -- like subclassing, you cannot just hit End or terminate your app from the debug window while GDI+ is running.
    :: As mentioned above, a little complicated for new users
    :: Does not support all older GDI functions. For example, you can't create an XOR pen with GDI+
    :: Requires extra steps to setup for drawing; but like anything new to you, just takes a little getting used to

    ___________________________________________________________________________
    Last Edited: Jan 21, 2010 8:50 PM GMT/Zulu
    :: Modified primarily for TIFF saving
    -- Can now save multiple images with/without attributes applied
    -- TIFF images can be saved in 1,4,8,24,32 bit depths - dependent upon source image depth
    :: Added another optional rendering quality setting when drawing: PixelOffsetMode
    :: Removed requirement of cGDIpRenderer to be passed token class during its function calls.
    -- Now entire class can be passed it one time via its AttachTokenClass method
    :: Single page TIFFs no longer cache their original source data; more memory savings
    Jan 19, 2010 2:20 AM GMT/Zulu
    :: Revamped quite a bit
    -- To reduce memory usage, PNG, BMP, & JPG no longer cache original data
    -- CloneImage routine still had some shortcomings when trying to clone without applying image attributes; fixed
    -- Fixed logic error reported by Jonney when cloning rotated images
    :: Added additional image types: imageIconPNG & imageCursorPNG to distinguish between PNGs loaded from ico/cur resources
    Jan 14, 2010 19:10 PM GMT/Zulu
    :: Found 2 memory leaks, one each in 2 different functions; fixed
    :: Changed logic when loading new images
    -- If new image then all attributes are reset automatically (were not before). Optional load flag prevents this.
    -- If multi-image format displays another image within same source; attributes remain (no change from previous logic)
    :: CreateCloneWithAttributes renamed to CreateClone. WithAttributes now an optional parameter
    :: ImageType property distinguishes between icons and cursors now
    :: Reorganized and cleaned up some routines
    :: Demo reworked a tad
    -- You can now apply multiple attributes to the same image and see results
    -- Included sample of saving a multi-page TIFF
    Jan 12, 2010 01:10 AM GMT/Zulu
    :: Added a little more functionality to the cGDIpImage class
    -- GetPixel, SetPixel, ExtraTransparentColor (similar functionality of TransparentBLT)
    :: Mirroring was off, had my constants swapped around, fixed
    :: When SaveAsOriginalFormat was applied for 32bpp alphablended bitmaps, was saved as 24bpp vs 32pp, fixed
    :: Updated demo a bit
    -- included SaveAsOriginalFormat, TransparentBLT examples
    -- included option to view any image in a multiple image format
    -- included option to view image info: size, depth, type
    Jan 11, 2010 01:30 AM GMT/Zulu
    :: Jonney helped identify a logic error when deciding whether 32bpp images use the Alpha channel and how it is used. Thanx Jonney
    ...
    Attached Files Attached Files
    Last edited by LaVolpe; Oct 26th, 2020 at 12:23 PM. Reason: updated comments
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width