NO

Author Topic: GdiPlus Library  (Read 31237 times)

JohnF

  • Guest
GdiPlus Library
« on: September 01, 2005, 10:20:54 PM »
Here is the GdiPlus code, hopefully someone will check it out and report any errors.

There is a A_README.TXT in the zip (zip is 152k).

EDIT: the zip is now 346k

http://www.johnfindlay.plus.com/pellesc/libs/GdiPlus.zip

Also, anyone who creates some GdiPlus code that others may find useful please contribute. There is a small example 'main.c' that uses some of the GdiPlus functions. I have also included the GdiPlus.lib (needed to link to the M.S. GdiPlus.dll) in case you don't have it.

Thanks.

John

JohnF

  • Guest
Re: GdiPlus Library
« Reply #1 on: September 02, 2005, 12:17:39 PM »
The GdiPlus library has been updated.

Mainly the structs have been re-named in a way that I think is more helpful. For example, all pseudo-class structs start with

GP_  i.e. GP_BRUSH

the other structs don't

RECTF, POINTI etc.

The reason I did this is because all pseudo-class structs need to be deleted using one of the Gp functions, whereas the normal structs do not.
 
The exception is the COLORMAP struct, it is re-named to COLOR_MAP because Windows has a COLORMAP.

Also added loading a PNG and playing an animated gif to the example code.

Also, added

GpImage_FromFileW
GpImage_FromFileA

for wide char and ACSII filenames.

The original GpImage_FromFile() has been removed.

The download is now 226k

The A_README.TXT has also been updated.

John

JohnF

  • Guest
GdiPlus Library
« Reply #2 on: September 03, 2005, 09:45:36 PM »
GdiPlus has been updated again.

From the README.TXT

I suggest making a folder ROOT:\PellesC\Include\GdiPlus\

and copy all headers which you will find in a separate zip,
(GdiPlusHeaders.zip) into that folder, then add into
TOOLS\OPTIONS and FOLDERS tab a new place for the compiler
to search for includes.

Example, the first two should already be set

d:\PellesC\Include
d:\PellesC\Include\Win
d:\PellesC\Include\GdiPlus

If you create any interesting example using this library please
send me a copy, I will make them available to others.

I have included the GdiPlus.lib that is used to link to the MS
GdiPlus.dll, it's in the folder 'MS_GdiPlus.Lib'

The GdiPlusLib.lib that includes all the library's functions
can be found in GdiPlusLib.zip, place in ROOT:\PellesC\Lib\
=================

From the HISTORY.TXT

(3nd September 2005)

Took out all xxx_SetStatus functions as they are a small
additional overhead, replaced with 'this->lastResult = '

Took out superfluous stuff from GdiPlusImaging.h

Changed names in GdiPlusImageAttributes .c & .h for consistency
with the rest of the library.

Took out function GpImage_FromFileA() - all functions in GdiPlusLib
that require strings are WideChar - to include one ASCII function
would not be consistent, making all functions have both WideChar
and ASCII would mean duplicating many functions.

Added these files

GdiplusImageCodec.c   GdiplusImageCodec.h
GdiplusFontCollection.c GdiplusFontCollection.h
GdiplusImageCodec.c  GdiplusImageCodec.h
GdiPlusLineCaps.c       GdiPlusLineCaps.h

And GdiPlus.h -- This includes all other headers and can be used as the only include in an application file. See GdiPlusExample.ppj

Added example of listing all GdiPlus Decoders
===================

Download from the link above in the first post. The zip size is now 384k.

John

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
GdiPlus Library
« Reply #3 on: September 05, 2005, 12:39:56 AM »
This looks really nice!  8)

It will probably take a while to learn enough to do anything useful...

I will include gdiplus.lib in the next beta release (to avoid the Microsoft library...)

Pelle
/Pelle

Mikehg

  • Guest
GdiPlus Library
« Reply #4 on: September 05, 2005, 06:35:53 AM »
Thanks John,

Will take a little time to digest this :)

Do you know of any sites with GDI+ samples to play with?

Thanks again,
Mike H.

JohnF

  • Guest
GdiPlus Library
« Reply #5 on: September 05, 2005, 06:35:55 AM »
Quote from: "Pelle"
This looks really nice!  8)

It will probably take a while to learn enough to do anything useful...

I will include gdiplus.lib in the next beta release (to avoid the Microsoft library...)

Pelle


Yes it will need quite a lot of work to learn, as it is quite large.

Thanks.

John

JohnF

  • Guest
GdiPlus Library
« Reply #6 on: September 05, 2005, 07:00:47 AM »
Quote from: "Mikehg"
Thanks John,

Will take a little time to digest this :)

Do you know of any sites with GDI+ samples to play with?

Thanks again,
Mike H.


Use Google - however there doesn't seem to be as much as one would expect.

Here the MS quide. I've looked at only a small part of this as yet, will be doing some more as time permits.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/usingGDIPlus.asp

John

Alessio

  • Guest
GpSolidBrush
« Reply #7 on: September 12, 2005, 03:37:37 PM »
Thank you for this userful library.
I've just a question: How to use GpSolidBrush function ?
Thank you.

JohnF

  • Guest
Re: GpSolidBrush
« Reply #8 on: September 12, 2005, 04:16:07 PM »
Quote from: "Alessio"
Thank you for this userful library.
I've just a question: How to use GpSolidBrush function ?
Thank you.


Sorry, it was wrong. Thanks for reporting it.

I have updated the library that one can download with the original link, or you can make the changes yourself -

Code: [Select]

 // Replace in GdiPlusBrush.c
 GP_BRUSH GpSolidBrush(COLOR * color)
 {
GpStatus lastResult;
GP_GPSOLIDFILL * brush = NULL;

lastResult = GdipCreateSolidFill(color->Argb, &brush);

return GpBrush_Brush((GP_GPBRUSH*)brush, lastResult);
 }

 // Replace in GdiPlusBrush.h
 GP_BRUSH GpSolidBrush(COLOR * color);

 // How to use.
 COLOR color = GpColor_4(255, 0, 0, 255);
 GP_BRUSH Brush = GpSolidBrush(&color);


John

Alessio

  • Guest
GpTextureBrush use
« Reply #9 on: September 13, 2005, 03:35:44 PM »
Hi,

sorry to bother you, I've another question for you:

It is the right way to use GpTextureBrush ?

GP_BRUSH brush;
GP_IMAGE image = GpImage_FromFile(L"foo.gif", FALSE);
GpTextureBrush(&brush, &image);

I'm porting some basics example of GDI+ from VB to PellesC.
There're taken from "Graphics Programming with GDI+" book.
You can obtain source code here:
http://www.c-sharpcorner.com/Store/Books/0-321-16077-0.asp

Thanks.

JohnF

  • Guest
GdiPlus Library
« Reply #10 on: September 13, 2005, 04:50:29 PM »
Yes, use it like that.

John

JohnF

  • Guest
GdiPlus Library
« Reply #11 on: September 17, 2005, 09:47:01 AM »
The GdiPlus library has been updated.

GpTextureBrush() had the same problem as GpSolidBrush(). GdiPlusBrush.c and GdiPlusBrush.h have been updated.

Here's the link again.

http://www.johnfindlay.plus.com/pellesc/libs/GdiPlus.zip

John

Tino

  • Guest
Save as JPG ?
« Reply #12 on: April 06, 2006, 02:25:32 AM »
Hello JohnF
Your Project is working fine.

I wondered if its possible to "save as jpg" using it.
I googled and found some code,
but i canĀ“t get it run ( its C-Sharp or something else.. )

Code: [Select]

private void ConvertFile(string src, string dest, int compress) {
// src = Sourcefile
// dest = Destination
// compress = Compression/Quality
// Load Bitmap bm = new Bitmap(src);

// Get the right Codec
ImageCodecInfo ici = null;
ImageCodecInfo[] iCodecs = ImageCodecInfo.GetImageEncoders();
foreach (ImageCodecInfo ic in iCodecs) {
if (ic.MimeType=="image/jpeg") {
ici = ic; break;
}
}
// Set EncoderParameters = Compression
ep = new EncoderParameters(1);
ep.Param[0] = new EncoderParameter(Encoder.Quality, compress);

// Save Bitmap
bm.Save(dest, ici, ep);
// Remove Bitmap
bm.Dispose();
}


Could you give me advice if it should run..
..and maybe how ?


Thanks
Tino

JohnF

  • Guest
GdiPlus Library
« Reply #13 on: April 06, 2006, 07:29:28 AM »
Tino,

Ok, I've done a small example and added a new page to my web site for GdiPlus examples. There is an example to load a BMP and saves it as a PNG and load a BMP and save a JPG specifying quality.

http://www.johnfindlay.plus.com/pellesc/GdiPlus/GdiPlus.htm

I would be good if people contributed any GdiPlus examples to my web site so that others can see how things are done.

John

Tino

  • Guest
GdiPlus Library
« Reply #14 on: April 06, 2006, 04:07:59 PM »
Hello JohnF,

THANKS for your "Supersonic Reaction" ;)
Your web site is a great resource !

No prob - I will post further questions to your site.

Thanks again
Tino