Sign in to follow this  
Followers 0
andybiochem

Graphic OVER GIF problem solved(?)

21 posts in this topic

#1 ·  Posted (edited)

Hi guys,

Not sure if this is the correct place for this, but thought it was a worthwhile share anyway.

(MODS: move this if you feel it's better off somewhere else)

Sorry if this is well known, or if it has been discussed before, I did a quick search to see if there had been a resolution to the problem but couldn't find this specific fix...

THE PROBLEM:

I've been creating a program that plots a line graph by use of the GUICtrlCreateGraphic function. Sending co-oordinates via a GUICtrlSetGraphic($graphic,$GUI_GR_LINE works well and a line is drawn.

However, if I now decide I want an image (GIF) as the background to the GUI, the image overwrites the graphic, and the graphic is no longer visible.

EXAMPLE:

This script...

CODE
#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

GUICreate("", 218, 207, 193, 115)

GUISetOnEvent($GUI_EVENT_CLOSE, "close")

GUICtrlCreateGraphic(25, 20, 171, 156)

GUICtrlSetBkColor(-1, 0xFFFFFF)

GUICtrlSetColor(-1,0)

GUICtrlSetGraphic(-1,$GUI_GR_HINT)

GUICtrlSetGraphic(-1,$GUI_GR_MOVE,20,20)

GUICtrlSetGraphic(-1,$GUI_GR_LINE,100,67)

GUICtrlSetGraphic(-1,$GUI_GR_LINE,150,40)

GUISetState(@SW_SHOW)

While 1

Sleep(100)

WEnd

Func close()

exit

EndFunc

...creates this graphic:

post-29091-1198144286_thumb.gif

And I want this gif image to be the background:

post-29091-1198144634_thumb.gif

...so i use

GUICtrlCreatePic("background.gif",0,0,0,0)

GuiCtrlSetState(-1,$GUI_DISABLE)

to add the image to the GUI in a disabled state.

But this happens...

post-29091-1198144885_thumb.gif

The GIF has overwritten the graphic box :)

THE SOLUTION:

The way to get the GIF 'behind' the graphic is to put a box of default windows gray where the graphic will be in the GIF, like this:

post-29091-1198145242_thumb.gif

(i.e. match the coordinates so the gray is DIRECTLY below the graphicbox, use 'shop or your fave graphic editor)

Loading this image into the GUI lets the graphic box show through...

post-29091-1198145351_thumb.gif

For some reason, windows treats the 'default gray' as a transparency and the graphic box is visible.

I've also found that different Windows Themes require a different 'default grays'.

For Windows Classic use : D4D0C8

For Windows XP use : ECE9D8

If you have a bespoke theme maybe the gray will be different again????

Maybe there is also a way to tell a program to recognise the theme type, or 'default gray' in use and load the correct GIF image so a graphic box will show through in all environments.

Cheers! ^_^

Edited by andybiochem

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites



Just a thought but have you tried setting the box to transparent instead of grey?


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Just a thought but have you tried setting the box to transparent instead of grey?

yes, also didn't work...

post-29091-1198157284_thumb.gif

(center of the GIF is transparent, not black)

Loaded into the script gives:

post-29091-1198157354_thumb.gif

can't see the graphic or lines.

:)

Edited by andybiochem

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites

Actually, this is a behaviour that has frustrated me to no end when I have had occasion to use images in my GUI's. It marks some areas of an image transparent, that just should not be. I was using an image, whose background was set to a pink color (0xff01ff to be precise), it was an image of a character from a video game. I was putting this image into a window with the $WS_EX_LAYERED exstyle, which caused the pink background to be completely transparent, but for some reason parts of his face, and arms were also transparent. And the problem is, as andybiochem suggested, the colours it chose as transparent changed depending on what my Windows colour scheme was using.

Share this post


Link to post
Share on other sites

yes, also didn't work...

(center of the GIF is transparent, not black)

Loaded into the script gives:

can't see the graphic or lines.

:)

Actually, that is a problem the way AutoIt interprets Gif files. If you set the top left pixel of the gif file to a transparent color, the center will actually become transparent as well.. Otherwise, AutoIt just puts a random color there.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Actually, this is a behaviour that has frustrated me to no end when I have had occasion to use images in my GUI's. It marks some areas of an image transparent, that just should not be. I was using an image, whose background was set to a pink color (0xff01ff to be precise), it was an image of a character from a video game. I was putting this image into a window with the $WS_EX_LAYERED exstyle, which caused the pink background to be completely transparent, but for some reason parts of his face, and arms were also transparent. And the problem is, as andybiochem suggested, the colours it chose as transparent changed depending on what my Windows colour scheme was using.

Yes, I've had similar problems, and in fact, if you look at the 3rd image in the originial post, you can see a 'glitch' to the left of the GUI where some of the graphic is in fact visible.

In this image below, I have done the following:

1) opened the original background GIF (2nd image in original post) in Photoshop 7

2) selected a small area in the middle and deleted it

3) the deleted area turned a light blue (my foreground and background colours were set to black and white in photoshop)

4) I used the 'select colour' tool and selected this new light blue area

5) The select colour tool shows up all areas that match the light blue in white

post-29091-1198159861_thumb.gif

The 'glitch' that can be seen in the 3rd image of the original post matches the area picked up by PS.

I'm not sure what is happening here, or where the light blue colour came from, but perhaps there is a solution related to this.....other than using my 'default gray' approach.

BTW does anyone know where the data for this default gray will be stored? The registry perhaps?

Edited by andybiochem

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites

Actually, that is a problem the way AutoIt interprets Gif files. If you set the top left pixel of the gif file to a transparent color, the center will actually become transparent as well.. Otherwise, AutoIt just puts a random color there.

tried that too, also didn't work:

post-29091-1198160330_thumb.gif

I'm not convinced this is totally an autoit bug.....could be wrong, I'm not too well versed in programming, but I'm ok with graphics and the like.


- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

My advice: Use MoveTo/LineTo API instead of GUICtrlSetGraphic

Look at my Radar project in my signature: Func MalujKriz() --> painting of red crosshair

Edited by Zedna

Share this post


Link to post
Share on other sites

Look at my Radar project in my signature: Func MalujKriz() --> painting of red crosshair

It doesn't work at all. Maybe it's very old (2005?)


The point of world view

Share this post


Link to post
Share on other sites

Is it the part of its anti-missile defence shield - a radar - in the Czech Republic? If so then it's great shield...

:)


The point of world view

Share this post


Link to post
Share on other sites

My advice: Use MoveTo/LineTo API instead of GUICtrlSetGraphic

Look at my Radar project in my signature: Func MalujKriz() --> painting of red crosshair

A good alternative, yes. I've also been looking at Auto3lib's use of GDI+ which also looks good.

However, I like the 'contained' nature of the graphic box...i.e. line coordinates outside the control are not drawn, only the area within the control boundaries are shown...that, and it's too deeply embedded in my script now, it'd be a nightmare to change.

Anyway, like I said, the 'defaullt-gray-box-in-the-gif' method works for now, but it would be nice to find a definitive answer as to why it happens.

Thanks for the input though!

:)


- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites

Is it the part of its anti-missile defence shield - a radar - in the Czech Republic? If so then it's great shield...

:)

Good point :-)))

It's meteo radar :-)

Look at picture radar.gif in my signature links.

Share this post


Link to post
Share on other sites

Good.

BTW. Can you expose the location of TV satellites on the sky?

This MAP of TV source would be very useful info, I think.


The point of world view

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Good.

BTW. Can you expose the location of TV satellites on the sky?

This MAP of TV source would be very useful info, I think.

Sorry I don't understand what exactly do you want.

Edited by Zedna

Share this post


Link to post
Share on other sites

Do you know about this site

http://www.lyngsat.com/

This site has list of satellites. But I (as many ones) don't know about the place of them on the sky. "MAP of TV source" is sky picture with names of sattelites. For example, Hotbird has Latitude 13°E, Intelsat 907 has Latitude=27.5°W and so on. Every satellite has TV provider or channel name. So the map of the sky with satellites will be map of the TV channels - MAP of TV source.

:)


The point of world view

Share this post


Link to post
Share on other sites

Do you know about this site

http://www.lyngsat.com/

This site has list of satellites. But I (as many ones) don't know about the place of them on the sky. "MAP of TV source" is sky picture with names of sattelites. For example, Hotbird has Latitude 13°E, Intelsat 907 has Latitude=27.5°W and so on. Every satellite has TV provider or channel name. So the map of the sky with satellites will be map of the TV channels - MAP of TV source.

:)

Now I understand your point but I can't do it. I think it's work for some graphic editor maybe.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Do you know about 'Satelitní televize'? If so then read about it for example here - http://www.digitalnitelevize.cz/forum/sate...evize-dvb-s.php

I know about this site. I read many informations about DVB-T (in which I'm very interested) from there already.

I don't have satelite receiver and I have no plans to get it in near future so I know only basic informations about it.

EDIT:

Are you speaking Czech Valery?

Edited by Zedna

Share this post


Link to post
Share on other sites

I know about this site. I read many informations about DVB-T (in which I'm very interested) from there already.

To get data directly from dish you have to have DVB-S card.

Here in Russia we have this safe solution by means (DVB-T/DVB-S card)

http://www.acorp.com.tw/download2.php?Id=40

DVB-S ($36) + 90 sm dish ($30) allow to create own and FREE IPTV&IPRadio intranet at home. There is also feature to get internet from there (chipest one). This is a very exiting subject to get experience in new branch of digital telecommunications.

Are you speaking Czech Valery?

No, but I understand content of that page as other from Czech Republic, Poland, Germany and other countries.

BTW. About "MAP of TV source". This map obtained by means dish allows to calculate the your coordinates on the Earth without any gps satellite service, I think.


The point of world view

Share this post


Link to post
Share on other sites

Czech republic is in the middle of terestrial digitalization process (from ending analog).

So in near future there will be about 15 TV programs on DVB-T (terestrial).

This is main reason why satelite is not so important for me and many others here.

But I agree it's good to know about others choices too.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0