Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Change picture color
Message
 
To
16/07/2004 09:11:22
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Miscellaneous
Thread ID:
00925117
Message ID:
00925713
Views:
13
This message has been marked as a message which has helped to the initial question of the thread.
>I have 3 pictures with transparent background.
>It is arrows picture, and close button. Those pictures are single-color pictures.
>The color of pictures for example (light-gray).
>When I change background color - I want to my pictures change color too..
>If background blue - pictures color is light-blue.. etc...
>
>Is there trick to create pictures which change color on fly, or repaint pictures.. or?

Take a look on GDI+ image class in the download section. It should contain MapColor() method. If this method is absent in that version, then here is its code:
	Procedure MapColor(tnOldColor, tnNewColor, tnOldAlpha, tnNewAlpha)
		If (Vartype(tnOldColor) != 'N') or (Vartype(tnNewColor) != 'N')
			Error 11
		EndIf
		If !Empty(tnOldAlpha) and (Vartype(tnOldAlpha) != 'N')
			Error 11
		EndIf
		If !Empty(tnNewAlpha) and (Vartype(tnNewAlpha) != 'N')
			Error 11
		EndIf

		Local argbOld, argbNew
		argbOld = This.MakeARGB(tnOldColor, tnOldAlpha)
		argbNew = This.MakeARGB(tnNewColor, tnNewAlpha)

		Local lnFormat, graphics, newImage
		lnFormat = 0
		graphics = 0
		newImage = 0

		This.stat = GdipGetImagePixelFormat(This.nativeImage, @lnFormat)
		This.stat = GdipCreateBitmapFromScan0(tnWidth, tnHeight, 0, lnFormat, 0, @newImage)
		If This.stat != 0
			Return
		EndIf
		This.stat = GdipGetImageGraphicsContext(newImage, @graphics)
		If This.stat != 0
			Return
		EndIf
		This.stat = GdipSetImageAttributesRemapTable(GpImageAttributes *imageattr,
                                 ColorAdjustType type,
                                 BOOL enableFlag,
                                 UINT mapSize,
                                 GDIPCONST ColorMap *map)
		This.stat = GdipDrawImageRectI(graphics, This.nativeImage, 0, 0, tnWidth, tnHeight)
		If This.stat = 0
			GdipDisposeImage(This.nativeImage)
			This.nativeImage = newImage
		EndIf
	EndProc
Previous
Reply
Map
View

Click here to load this message in the networking platform