Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using GDI+ for changes from color to Gray
Message
From
09/05/2008 09:35:46
Arnold Lee
K&A International Co.,Ltd
Hong Kong, Hong Kong
 
 
To
09/05/2008 08:18:43
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01315104
Message ID:
01316063
Views:
31
Hello Cesar

Tks for all, i am apologize for the mail I sent to you privately. I just want to attach photo to explains my case for you visually.Ok I understand your idea and will post the question here afterward.

Tks for your idea. I am now clear what i really is convert the image to half tone. I will study material you mentioned and let you know when i found something.

Tks again.Have a nice weekend

Regards
Arnold



>Hi Arnold,
>
>My suggestion is that you fist convert the image to GreyScale, using the colormatrices samples from my article in UT.
>This conversion is done super fast, almost instantly.
>
>Then, choose to save your image in GIF format.
>It will use the basic color pallette, and the image will loose quality, but I think that this is the effect you are looking for.
>
>GIFs are 8bpp, and in the basic palette there are some grey options, so I think your result will be the desired one.
>
>
>Try this, and tell me if the results are satisfactory.
>
>
>
>GDI+ has another method that allows image manipulation, but the results are not instantaneous as the ones I provided above. Look for LockBits method in the .NET samples. Also I've added a cool sample in the SAMPLES of GdiPlusX. Look for 2 samples:
>
>- LockBits.scx
>- TransparentGifs.scx
>
>
>If this is still not good, then we can use another API, OLECREATEIMAGEINDIRECT, that brings always 4bpp images. In GdiPlusX, in the xfcIcon class this function is used, if you need a sample.
>
>
>Hope this helps
>
>Cesar
>
>
>PS: PLEASE, don't send technical questions via to my private email.
>I really don't understand why you did that, specially because I was giving you support via UT.
>I'm not the only one that deals with this, and there are other developers that visit UT frequently that know much more than me on this subject.
>Posting your questions in a public forum, gives you the oportunity to receive other suggestions.
>And someone else can provide some different ideas, and better aproaches than me. I really hope someone else comes with a new suggestion, so that I can learn new things as well.
>
>Apart from this, other people may have the same question, and this will help them too.
>Posting questions in a public forum also stimulates the use of the tool.
>
>I never meant to offend you with this. Maybe I chose some wrong words above.
>I'm here to try to help you.
>
>Regards
>
>Cesar
>
>
>
>
>
>>Hello Cesar
>>
>>Apart from GetMonoChrome() to return 1 bppindexer bitmap.Is it any alternatvie function to return 4bppindexer bitmap ?
>>
>>Tks
>>
>>Regards
>>Arnold
>>
>>>Arnold,
>>>
>>>But those functions, GetPictureVal() and GetPictureValFromHBitmap() are available for the Bitmap and Image classes, that are almost obligatory for resizing an image.
>>>
>>>Post here the code you are using and I'll show you how you can apply to your code
>>>
>>>
>>>
>>>
>>>>Hello Cesar
>>>>
>>>>Tks for your input.It works like a charm.
>>>>Used to I uses GDI to made thumbnail and save as a file and uses filetostr() to get the string and save to memo field.Of course it works but have to erase the tmp file everytime.may it would be nice if simialr function is available on resize function of gdiplusx.
>>>>
>>>>Thank you very much.
>>>>
>>>>Arnold
>>>>
>>>>
>>>>>Very simple too.
>>>>>
>>>>>The most simple aproach is to use either GETPICTUREVALFROMHBITMAP() or GetPictureVal() functions.
>>>>>
>>>>>For more options, please read carefully the commented lines:
>>>>>
>>>>>
>>>>>
** HOWTO: Get a Monochromatic 1 bit per pixel image
>>>>>
>>>>>DO LOCFILE("System.App")
>>>>>
>>>>>WITH _SCREEN.System.Drawing
>>>>>   * Create a Bitmap object based on a BMP file.
>>>>>   LOCAL loOriginalBmp AS xfcBitmap
>>>>>   loOriginalBmp = .Bitmap.New(GETPICT())
>>>>>
>>>>>   LOCAL loMonoChrBmp as xfcBitmap
>>>>>   loMonoChrBmp = loOriginalBmp.GetMonochrome()
>>>>>
>>>>>   * Dispose the original Bitmap because we don't need it any more
>>>>>   loOriginalBmp = NULL
>>>>>	
>>>>>   * Save the created Monochromatic Bmp
>>>>>*   loMonochrBmp.Save("c:\Monochromatic.bmp", .Imaging.ImageFormat.Bmp)
>>>>>
>>>>>   * Get the Image binaries directly:
>>>>>   LOCAL lcImgBinaries
>>>>>   lcImgBinaries = loMonochrBmp.GetPictureValFromHBitmap()
>>>>>
>>>>>   * For a different image format than BMP, a little slower, but if you use this the image format will not be 1bpp any more:
>>>>>*   LOCAL lcImgBinaries
>>>>>*   lcImgBinaries = loMonochrBmp.GetPictureVal(.Imaging.ImageFormat.Jpeg)
>>>>>
>>>>>
>>>>>ENDWITH
>>>>>
>>>>>RETURN
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>Thanks for gdiplusx. getmonochrome() and example start me up.
>>>>>>
>>>>>>May i know is it possible to return a binary stream (like from filetostr()) from xfcBitmap object so i can save the string to memo file rightaway ?
>>>>>>
>>>>>>Thank you.
>>>>>>
>>>>>>
>>>>>>>>Dear Cesar
>>>>>>>>
>>>>>>>>How are you ?
>>>>>>>>I know you are very interested in using GDI :)
>>>>>>>>In fact, i would like to convert the color jpg to 1bit black/white file for special purpose printing. could you enlighting me ? Tks
>>>>>>>>
>>>>>>>
>>>>>>>See if this helps you:
>>>>>>>
>>>>>>>PS: Requires GdiPlusX
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
** HOWTO: Get a Monochromatic 1 bit per pixel image
>>>>>>>
>>>>>>>DO LOCFILE("System.App")
>>>>>>>
>>>>>>>WITH _SCREEN.System.Drawing
>>>>>>>   * Create a Bitmap object based on a BMP file.
>>>>>>>   LOCAL loOriginalBmp AS xfcBitmap
>>>>>>>   loOriginalBmp = .Bitmap.New(GETPICT())
>>>>>>>
>>>>>>>   LOCAL loMonoChrBmp as xfcBitmap
>>>>>>>   loMonoChrBmp = loOriginalBmp.GetMonochrome()
>>>>>>>
>>>>>>>   * Dispose the original Bitmap because we don't need it any more
>>>>>>>   loOriginalBmp = NULL
>>>>>>>	
>>>>>>>   * Save the created Monochromatic Bmp
>>>>>>>   loMonochrBmp.Save("c:\Monochromatic.bmp", .Imaging.ImageFormat.Bmp)
>>>>>>>ENDWITH
>>>>>>>
>>>>>>>RETURN
Previous
Reply
Map
View

Click here to load this message in the networking platform