Video display modes: Difference between revisions

m
→‎{{header|Wren}}: Removed a blank line
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Removed a blank line)
 
(11 intermediate revisions by 3 users not shown)
Line 376:
9010 get k$:if k$="" then 9010
9020 return</syntaxhighlight>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
Delphi is primarily a language used under advanced operating systems such as Windows, Linux and iOS. Under Windows, the video resolution and color depth is controlled by Windows, the monitor, the video card and the choices of the user. These days, color is almost always set to 32-bit pixels with 8-bits for Red, Green and Blue, plus an alpha channel for transparency. Most people run their displays at 1080P resolution or higher. So under Windows, you typically have the highest possible resolution. Given these resolutions and the size of monitors these days, there is so much graphics real estate on the average display, that most programs only need to use a portion of the screen to display all their information.
 
Under these circumstances, the only way you could change the screen resolution or color depth would be to change it downward. The only reason you'd ever want lower resolution displays is if you were simulating the pixelated, low quality graphics of old computers. And, if you really want to display a low graphics, it is pretty easy to simulate it with high resolution graphics.
 
Delphi supports working in the world of high resolution displays by allowing you to easily create windows that are sizable by the programmer or the user. It supports putting text in a window with components like the "TMemo" object. Likewise, you can draw or put images into a window with the "TImage" component.
 
As an example of how this works, here is some code that would wrote text into a text window:
 
<syntaxhighlight lang="Delphi">
begin
Memo.Line.Add('Hello World');
end;
</syntaxhighlight>
 
Here's an example of drawing lines in a graphics window;
 
<syntaxhighlight lang="Delphi">
 
begin
Image.Canvas.MoveTo(0,0);
Image.Canvas.LineTo(100,100);
end;
 
 
 
 
</syntaxhighlight>
{{out}}
[[File:DelphiMemoWindow.png|frame|none]]
[[File:DelphiImageWindow.png|frame|none]]
<pre>
 
</pre>
 
=={{header|ERRE}}==
Line 551 ⟶ 588:
 
{{omit from|J}} This isn't a J issue, it's an OS issue. Thus, for example, we could use <code>2!:0'xrandr -s 640x480'</code> on an operating system where that provides meaningful behavior. And, we could use <code>shell'mode CON: COLS=40 LINES=100'[require'task'</code> on an operating system where that provides meaningful behavior (and <tt>2!:0</tt> does not work on windows -- on linux this <tt>shell</tt> command is equivalent to <tt>2!:0</tt>). But these won't work in the general case of an arbitrary operating system and arbitrary video hardware, and it's probably best handle such tasks before starting J.
 
=={{header|Java}}==
<syntaxhighlight lang="java">
 
import java.awt.Color;
import java.awt.DisplayMode;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.util.concurrent.TimeUnit;
 
import javax.swing.JFrame;
import javax.swing.JLabel;
 
public final class VideoDisplay {
public static void main(String[] aArgs) throws InterruptedException {
GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] screens = environment.getScreenDevices();
System.out.println("Number of video screens: " + screens.length + System.lineSeparator());
for ( GraphicsDevice screen : screens ) {
System.out.println("Full screen display is supported: "
+ screen.isFullScreenSupported() + System.lineSeparator());
GraphicsConfiguration[] configurations = screen.getConfigurations();
System.out.println("This screen has number of configurations: " + configurations.length);
for ( GraphicsConfiguration config : configurations ) {
System.out.println("Configuration supports translucency: " + config.isTranslucencyCapable());
}
DisplayMode[] modes = screen.getDisplayModes();
System.out.println(System.lineSeparator() + "This screen has " + modes.length + " modes of operation");
for ( DisplayMode mode : modes ) {
System.out.println(mode.getWidth() + " X " + mode.getHeight()
+ " with refresh rate " + mode.getRefreshRate() + " Hz");
}
}
// Uncomment the line below to see an example of programmatically changing the video display.
// new VideoDisplay();
}
private VideoDisplay() throws InterruptedException {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Video Display Demonstration");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBackground(Color.LIGHT_GRAY);
frame.add( new JLabel(MESSAGE) );
frame.setSize(800, 600);
GraphicsDevice screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
DisplayMode originalDisplayMode = screen.getDisplayMode();
screen.setFullScreenWindow(frame);
screen.setDisplayMode( new DisplayMode(800, 600, 32, 60) );
frame.setVisible(true);
TimeUnit.SECONDS.sleep(3);
screen.setDisplayMode(originalDisplayMode);
TimeUnit.SECONDS.sleep(3);
Runtime.getRuntime().exit(0);
}
private static final String MESSAGE = "Please wait for a few seconds."
+ " Your video display will then be returned to its original setting.";
}
</syntaxhighlight>
{{ out }}
<pre>
Number of video screens: 1
 
Full screen display is supported: true
 
This screen has number of configurations: 1
Configuration supports translucency: true
 
This screen has 11 modes of operation
640 X 480 with refresh rate 60 Hz
800 X 600 with refresh rate 60 Hz
1024 X 768 with refresh rate 60 Hz
1128 X 634 with refresh rate 60 Hz
1280 X 720 with refresh rate 60 Hz
1280 X 1024 with refresh rate 60 Hz
1366 X 768 with refresh rate 60 Hz
1600 X 900 with refresh rate 60 Hz
1680 X 1050 with refresh rate 60 Hz
1760 X 990 with refresh rate 60 Hz
1920 X 1080 with refresh rate 60 Hz
</pre>
 
=={{header|Julia}}==
Line 878 ⟶ 1,010:
=={{header|Wren}}==
The ability to call external processes such as ''xrandr'' is expected to be added to Wren-cli in the next release. In the meantime, we embed the following Wren script in a minimal C host (no error checking) to complete this task.
<syntaxhighlight lang="ecmascriptwren">/* video_display_modesVideo_display_modes.wren */
 
class C {
Line 902 ⟶ 1,034:
<br>
We now embed this in the following C program, compile and run it.
<syntaxhighlight lang="c">#include/* <stdiogcc Video_display_modes.h>c -o Video_display_modes -lwren -lm */
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Line 959 ⟶ 1,093:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "video_display_modesVideo_display_modes.wren";
char *script = readFile(fileName);
wrenInterpret(vm, module, script);
9,483

edits