重拾VB6(26):color, picutre object, printing

本文介绍了Visual Basic中颜色值的表示方法及其在不同显示环境下的应用,包括256色调色板的工作原理、图片对象的使用及打印方法。

来自MSDN-2001-OCT: Visual Tools and Languages/Visual Studio 6.0 Documentation/Visual Basic Documentation/Using Visual Basic/Programmer’s Guide/Part 2: What Can You Do With Visual Basic/Working with Text and Graphics/

1. Color Value

(1) Visual Basic uses a consistent system for all color properties and graphics methods. A color is represented by a Long integer, and this value has the same meaning in all contexts that specify a color.

(2) There are four ways to specify a color value at run time: RGB function, QBColor function, intrinsic constants, Enter a color value directly. 另外,还可以用system colors(随系统设定而变化)。

2. Color Palette

(1) Visual Basic displays metafiles using the default palette of 16 VGA colors.

(2) The hardware palette contains 256 entries defining the actual RGB values that will be displayed on screen. The system halftone palette is a predefined set of 256 RGB values made available by Windows itself. A logical palette is a set of up to 256 RGB values contained within a bitmap or other image.

Windows can draw using the 256 colors in the hardware palette. Twenty of these 256 colors, called static colors, are reserved by the system and cannot be changed by an application. Static colors include the 16 colors in the default VGA palette (the same as the colors defined by Visual Basic’s QBColor function), plus four additional shades of gray. The system halftone palette always contains these static colors.

The foreground window (the window with focus) determines the 236 nonstatic colors in the hardware palette. Each time the hardware palette is changed, all background windows are redrawn using these colors. If the colors in a background window’s logical palette don’t perfectly match those currently in the hardware palette, Windows will assign the closest match.

On true-color (16-million color) displays, Visual Basic always uses the correct color. On monochrome or 16-color displays, Visual Basic will dither background colors and colors set with the FillColor property. Dithering is a process used to simulate colors not available from the video adapter and display driver.

With 256-color video drivers, you can use up to 256 colors with graphics methods. By default, the 256 colors available in Visual Basic are those in the system halftone palette. Although you can specify an exact color using the RGB function, the actual color displayed will be the closest match from the halftone palette.

Although the default palette for Visual Basic is the system halftone palette, you can also control the display of colors with the PaletteMode and Palette properties of forms, user controls, and user documents. In this case, the color match is much the same, except that colors will be matched to the closest color in the hardware palette.

(3) The PaletteMode property only applies to 256-color displays. On high-color or true-color displays, color selection is handled by the video driver using a palette of 32,000 or 16 million colors respectively. Even if you’re programming on a system with a high-color or true-color display, you still may want to set the PaletteMode, because many of your users may be using 256-color displays.

(4) 总之,为256色系统设计时,在调色板方面有许多需要额外考虑的问题。

3. Using the Picture Object

(1) You could think of the Picture object as a invisible picture box that you can use as a staging area for images:

Private Sub Command1_Click()
   Dim objPic As Picture
   Set objPic = LoadPicture("Butterfly.gif")
   Set Picture1.Picture = objPic
End Sub

(2) There are lots of things you can do with bitmaps, icons, or metafiles in the Windows API, but the Picture object already does most of them for you.

There are now two completely different ways to paint graphics on a window (or blit). You can use BitBlt or StretchBlt on the hDC of an object, or you can use the PaintPicture method on the Picture object or property. If you have an Image control, you can only use PaintPicture because Image controls do not have an hDC.

There is no direct relationship between a Picture.Handle and a PictureBox.hDC. The hDC property of the picture box is the handle provided by the operating system to the device context of the picture box control. The Handle property of the Picture object is actually the handle of the GDI object that is contained in the Picture object.

4. Printing

(1) The code in your application determines the type and quality of print output available from your application. But the users’ printer drivers and printers also impact print quality.

(2) 从程序里打印有3种方法:printform,用打印机列表(控制面板里列出的)里的printer,或者用printer object.

其中Printer object打印效果最好。不过它用起来也最麻烦,要写最多的代码,打图的时候也比较占资源。详见:Printing with the Printer Object。

源码来自:https://pan.quark.cn/s/41b9d28f0d6d 在信息技术领域中,jQuery作为一个广受欢迎的JavaScript框架,显著简化了诸多操作,包括对HTML文档的遍历、事件的管理、动画的设计以及Ajax通信等。 本篇文档将深入阐释如何运用jQuery达成一个图片自动播放的功能,这种效果常用于网站的轮播展示或幻灯片演示,有助于优化用户与页面的互动,使网页呈现更加动态的视觉体验。 为了有效实施这一功能,首先需掌握jQuery的核心操作。 通过$符号作为接口,jQuery能够迅速选取DOM组件,例如$("#id")用于选取具有特定ID的元素,而$(".class")则能选取所有应用了某类class的元素。 在选定元素之后,可以执行多种行为,诸如事件监听、样式的变更、内容的更新以及动画的制作等。 关于“一个基于jQuery的图片自动播放功能”,首要任务是准备一组图片素材,这些素材将被整合至一个容器元素之中。 例如,可以构建一个div元素,将其宽度设定为单张图片的尺寸,再借助CSS实现溢出内容的隐藏,从而构建出水平滚动的初始框架。 ```html<div id="slider"> <img src="image1.jpg" alt="Image 1"> <img src="image2.jpg" alt="Image 2"> <!-- 更多图片内容... --></div>```接着,需要编写jQuery脚本以实现图片的自动切换。 这通常涉及到定时器的运用,以设定周期性间隔自动更换当前显示的图片。 通过使用`.fadeOut()`和`.fadeIn()`方法,能够实现图片间的平滑过渡,增强视觉效果。 ```javascript$(document).re...
根据原作 https://pan.quark.cn/s/eb05e63067ef 的源码改编 Vulkan在现代图形编程领域被视为一种高效且低层级的API,它赋予开发者对硬件资源的直接支配权,从而在游戏开发、专业级渲染以及计算密集型应用中达成卓越的性能表现。 MoonVulkan作为一个针对Vulkan API的Lua语言绑定库,显著简化了使用Lua来编写Vulkan图形程序的过程。 Lua作为一种轻量级脚本语言,因其语法精炼且易于集成,经常被应用于游戏开发以及其他需要快速构建原型设计的场景。 MoonVulkan的核心宗旨是将Vulkan的强大功能引入Lua编程环境,使得开发者能够借助Lua的简洁语法来处理复杂的图形作业。 这个库提供了一套完整的Vulkan函数和结构体的Lua接口,使得Lua程序员可以直接运用Vulkan API的各类功能,例如构建设备、管理交换链、提交命令缓冲区等操作。 在MoonVulkan框架内,开发者可以运用Lua的动态属性,例如在执行期间检查错误、执行条件性判断以及循环操作,这些在C++或C语言中通常需要编写大量的辅助代码才能完成。 再者,得益于Lua的脚本特性,MoonVulkan支持热更新机制,即在程序运行过程中可以调整图形逻辑,无需对整个项目进行重新编译。 在运用MoonVulkan时,有几个关键性概念需要掌握:1. **Vulkan的初始化设置**:必须配置Vulkan实例,这是所有Vulkan操作的基础环节。 这包含选取物理设备(代表GPU)、构建一个恰当的实例配置,并妥善处理所需的扩展和层。 2. **表面的构建**:在桌面平台环境下,这通常涉及与窗口系统的互动,以获取一个象征屏幕输出的VkSurfaceKHR对象。 3. **图形与计算队列的选择...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值