• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FS2004 Scale a Bitmap?

tgibson

Resource contributor
Messages
11,860
Country
us-california
Hi,

We are creating a LORAN gauge, which was used a while back for navigation. It uses an oscilloscope screen, and one step is to adjust the height of the peaks. I was going to use a bitmap of an oscilloscope trace for the display, but I am wondering if I can scale the bitmap using XML code (much like a <Shift> command but changing its size rather than moving it), and even better if you can scale it in only one direction (i.e. vertically)?

Thanks,
 
I don't think it is possible with XML unfortunately, however what about drawing all the bitmap states (oscillations of the oscilloscope trace) and then make them visible one a time using visibility, like a kind of animation?
Maybe pure nonsense but worth trying:p..
 
Probably many ways to do this, here's one.
In layers from bottom to top -
1) A "silly" scope background that includes your volts/div & time/div markings
2) Use shift-X to move the arbitrary waveform up and down
3) Use a mask image for above (#2) to keep the waveform from extending past the "silly" scope screen

Used something similar but way more complex in the F-111 e-scope in TFR mode, all in XML.
The waveform moved in both the X&Y directions with other factors also involved.

Roman
 
Experimented a bit to try to scale a bitmap, and like all other posts said, scaling is reserved only for drawn rectangles. :mad:
High doses of coffee kept me going and created a little "silly" scope that responds to voltage levels by percentage.
Used FS9 schema, tested in FSX but should work in FS9.. Nothing special.
103 bitmaps! 3 are 24bit, the rest are 1bit.
Made a couple of VBasic programs to 1) make 99 other resized bitmaps based on the 100% bitmap and 2) A program to write the mind numbing repetitive xml code.
C#:
        Dim newText As String = ""
        FileOpen(1, "C:\Users\Me\Desktop\New folder\out.txt", OpenMode.Output)
        For j = 1 To 99
            newText = newText + vbCrLf + "<Case Value=$" + j.ToString + "$><Image Name=$sine_" + j.ToString + ".bmp$ Bright=$Yes$/></Case>"
        Next
        Write(1, newText)
        FileClose(1)
          'AFTER THE WRITE ALL DOLLAR SIGNS GET REPLACED WITH QUOTES        
        
'---------------------------------------------------------------------------------------------------------------------
    Public Shared Function ResizeImage(ByVal InputImage As Image, ByVal NewHeight As Integer) As Image
        Return New Bitmap(InputImage, New Size(620, NewHeight))
    End Function
  
        Dim origBM As New Bitmap("C:\Users\Me\Desktop\New folder\sine_100.bmp")
        Dim newBM As Bitmap
        Dim newHeight As Integer     

        For j = 1 To 99
            newHeight = CInt(314 * (j / 100))
            newBM = ResizeImage(origBM, newHeight)
            newBM.Save("C:\Users\Me\Desktop\New folder\sine_" + j.ToString + ".bmp")
        Next
After the bitmaps were resized they were run thru a Irfanview batch, centering the resized bitmaps on a common canvas size & reducing colors down to 1 bit.
The random generator code from the wiki here provides "lifelike" silly scope rendering with poor input impedance & terrible triggering.

All in all it took about an hour & a half.
View it in action here, Also attached.
 

Attachments

Last edited:
Coffee always accompanies Roman's best work...

In your F-111, I thought you simply used a couple hundred <Element><Polyline><Shift> to move a short, like 1 gauge pixel wide, point up and down, the advantage being that you could apply an algorithm to the Y shift.

Bob
 
Hi,

Nice! That definitely tells me the multiple bitmap method is the way to go.

Thanks Roman,
 
In your F-111, I thought you simply used a couple hundred <Element><Polyline><Shift> to move a short, like 1 gauge pixel wide, point up and down, the advantage being that you could apply an algorithm to the Y shift.

Bob, yes, did it that way because Steve wanted the color/brightness/contrast to be adjustable, hence the polyline. That bit if coding took weeks in order to get right, :banghead:
 
Color, brightness, contrast. Interesting. The only thought I had was that it gave you a lot of flexibility to control the Y shift - which it undoubtedly does.

The sine wave bmps are very lively, I'll give you that!

Hope you never run low on jo

Bob
 
And .... You got into PID work on the elevators to control TFR flight. Talk about tedious and time consuming!
 
Roman,

Nice work! I just downloaded the gauge and will check out the thing tonight. If I can make heads or tails of the code would it be possible to use the "logic" behind it for the "noise" you may find when initially tuning the station pairs that appear in the O-Scope?

Also, I'm still learning the whole xml thing - even after six months - so I have a few questions.

1. I was wondering if the code above in your post are the "programs" that make the 100% image into the various other images and xml code? Is it xml?
2. I have Ifranview but haven't done any batch processing with it. Is it something that you do from the GUI or from the command prompt like with imagetool? If so, how?
3. Is it possible to do this with the regular 8-bit indexed image with mask, or do the images have to be 1-bit? I ask since I have a particular shade of green color I'm using for the sine waves I've made so far.
4. I understand the macro is available to get (at least the code) from the wiki here. How did you come about any other calculations you would need for the gauge to work? Is there a reference of some sort?

We're hoping to use the distance already known by FS's GPS engine to our advantage. The real AN/APN-4 unit (and all LORAN) used microsecond measurements over several "sweeps" to get the distance from the stations. You would then add the different readings and get a total of microseconds that you then checked on a map. Since the hyperbolic calculations are way above my head, I was thinking of using the distance that we already know from each station. The gauge calculates the difference in distance between the aircraft and the two stations that are tuned. This is the distance taken at the "snapshot" saved in the L:Var. Is is then converted to microseconds. These microseconds in turn would be multiplied by 1000 in order to get the number of microseconds (reference to 1000 units) that would be displayed on a virtual notepad on the gauge. The trick is how to get this measurement as a component of three readings on the scope on scales of 1-10, 1-100, and 1-1000. As I said, in reality you added these different readings to get to the final number which you checked against a LORAN chart. We're trying to work it from the other way around - get the three numbers from the difference in distance you already know from the sim.

As an example, let's say the microseconds for the first measurement was 25, the second was 200, and the third was 3000. The total would be 3,225 when added. With FS, we know the 3,225 aready because we got it from the distance we just converted. The trick is to figure out how to get the gauge to subtract the 25, then the 200, from the 3,000 leaving the three different components that make up the number. Being a "dynamic" number that will change, I'm not sure how the math would be for this.

The real unit had a tolerance of error of 2% at 1,400 miles. This is about 28 miles from various documents Tom and I have found around the net. In Excel I was using 6,000 even as the number of feet for a nautical mile instead of converting everything to meters and then using 1,852 which is exact. I decided to do this to simulate the error that would be inherrent. The error I got at an input of 1,400 miles was 16 miles, so even with an incorrect setting for feet per nautical mile it still gave a better "error" reading than the original unit.

The map is on the back burner until the unit has some sort of interaction with the sim other than just giving generic info and allowing you to spin a few knobs and flip a few switches.

Thanks in advance for this gauge and looking forward to any feedback!

Regards,

Jorge
Miami, FL
 
1. I was wondering if the code above in your post are the "programs" that make the 100% image into the various other images and xml code? Is it xml?
No, it is VisualBasic from the Visual Studio 2019 toolset. Those were used in order to make the repetitive bitmaps and resulting xml code. Took much less time to write that code to do it rather than using photoshop & editing the xml code directly..

2. I have Ifranview but haven't done any batch processing with it. Is it something that you do from the GUI or from the command prompt like with imagetool? If so, how?
From the GUI in Irfanview: File | Batch Conversion / Rename
A quick visual tutorial.. Play with it using sacrificial bitmaps to learn more.
Irfanview_Batch.png

3. Is it possible to do this with the regular 8-bit indexed image with mask, or do the images have to be 1-bit? I ask since I have a particular shade of green color I'm using for the sine waves I've made so far.
Sure! I just used 1 bit to keep the 100 bitmaps sizes low. (gauge overhead) If you are using only 1 color for the green, you could if wanted, change the 1 bit (2 colors) palette to include the green. Color 0 = 0,0,0 Color 1 = "your green"
But.. That would most likely have to be done using a image program, 1 file at a time.. :banghead:
4. I understand the macro is available to get (at least the code) from the wiki here. How did you come about any other calculations you would need for the gauge to work? Is there a reference of some sort?
No other calculations, the voltage knob adjusts the amplitude. The macro adds poor waveform trigger noise in the X direction <Shift>, the macro also adds poor "front end" electronic noise to the amplitude (Y).
Voltage knob + Noise ( nearest integer, limit value 1-100 ) --> select amplitude bitmap.

Will need to read through your description, multiple times (with lots of coffee! :p) in order to get a grasp of what you are trying to do.
The example above was just that.. A quickly made example, but working only with amplitude. (Y)
Working with time (time/division) will be much more difficult because the waveform "shape" actually changes resulting making the bitmaps quite a chore, some batching, and a lot of hand editing (fitting, repeating to canvas).
Working in both in the X/Y would square the amount of bitmaps needed! Could always reduce the resolution (currently 100 in the Y) to help.

An option if wanting both X&Y without using 10,000 bitmaps @ 100 resolution.. It would require you to relinquish a "full simulation" in the Y direction. You would use only the top half of the waveform with the scope's "zero line" being at the bottom. The result would be a clipped waveform (think diode) but still able to measured in the X using the peaks or the crossings of the "zero point" on the scope.
Example:
example.png


I can see further morning projects with the coffee! Just for fun.
 
Last edited:
Roman,

Thanks for the feedback on this. If you would like I can put you in the distro for the next update I'm hoping to send out tomorrow.

Meanwhile, here is the unit I used to make the image. I worked from these pictures available at the National Air and Space Museum website:

https://airandspace.si.edu/collection-object/oscilliscope-loran-id-6b-apn-4/nasm_A19940030000

Here are a few images Tom was able to send me to help me understand. There are also many other resources, but these are the ones I'm using to make the wave bmp files from:

Page 1.jpg
Page 2.jpg
Page 3.jpg
Page 4.jpg
Page 5.jpg
Page 6.jpg


Here are a few of the unit. With the exception on one shot, all are static for now. It's missing the knobs and switches since this is taken from the mask image to cover the traces in the back behind the scope (like an artificial horizon):

01_apn4_main_pre_pedestal.png
02_apn4_main_pedestal.png
04_apn4_main_sine.png
06_apn4_main_sine.png


Still much work to do, but getting there. All the waves need to do is move left and right for the first two, and move left and right AND amplify or de-amplify for the "humps". Moving multiple bmp files may be a bit of a chore, so it may just be the multiple bmp files for the amplitude for now. So far the only one I have "reacting" to any input is the dual sine wave hump one, and that is with the amp balance knob. You use the Filter switch on the left unit to flip between the A station and the B station and adjust the waves individually - Filter IN for the A (upper) sine wave and Filter OUT for the B (lower) sine wave. For the "pedestal" images, the top pedestal and the bottom spike should not move. You adjust the top spike left and right with the left right switch and fine tune with the crystal phasing knob. The coarse and fine delay perform the same funtion to move the bottom pedestal to the bottom spike.

Again, that's the way it's supposed to work once I can get the bmp files done and the coding to the thing. I'm grateful for all the help I can get and those that have given input have been invaluable so far, so the more the merrier.

Thanks for the feedback on this, it's much appreciated!

Jorge
Miami, FL

PS: I was hoping to use the "random" number macro to have the "noise" running in the background like you would with real interference on a scope showing radio frequency usage, hence the interest in the "not so silly" scope!
 
Back
Top