http://www.newton-inc.com/dev/techinfo/qa/qa.htm
SetLCDContrast
, to do just that. However, changing the contrast with no end user control is not considered a good user-interface practice.ScaleShape
?MungeBitmap
, it sometimes shifts the data. How can I rotate left correctly?MungeBitmap
using these operations: 'flipHorizontal
, 'flipVertical
, and 'rotateRight
. ('rotateRight
three times will work as well, but it is less efficient bacause flips are faster than rotates.)MakeBitmap
and copy data into the bitmap.GetPICTAsBits
). If you want to create bitmaps dynamically at compile time, you can create a simple bitmap object with the following format.{
bounds: <bounds frame>,
bits: <raw bitmap data>,
mask: <raw bitmap data for mask - optional>
}
Binary object <raw bitmap data> - class 'bits
bytes data-type descr
0-3 long ignored
4-5 word #bytes per row of the bitmap data
(must be a multiple of 4)
6-7 word ignored
8-15 bitmap rectangle - portion of bits to use--see IM I
8-9 word top
10-11 word left
12-13 word bottom
14-15 word right
16-* bits pixel data, 1 for "on" pixel, 0 for off
MakeBitmap
global function, use the GetShapeInfo
function to get the bitmap and other slots required to interpret the meaning of the bitmap created by MakeBitmap
. GetShapeInfo
or the following slots for images created by other applications, images stored in the Newton ROM, images created with functions other than MakeBitmap
, nor images with a depth other than 1.MakeBitmap
of depth
1, the return value of GetShapeInfo
contains frame with information you can use to interpret the bitmap data.bits
slot referencing the bitmap data for the bitmap. This bitmap data can be manipulated at run time (or copied for non-Newton use), using other slots in the return value of GetShapeInfo
to interpret the bitmap binary object: scanOffset
, bitsBounds
, and rowBytes
. For instance, the first bit of the image created with MakeBitmap
can be obtained with code like: bitmapInfo := GetShapeInfo(theBitmap);
firstByte := ExtractByte(bitmapInfo.bits, bitmapInfo.scanOffset);
firstBit := firstByte >> 7; // 1 or 0, representing on or off
rowBytes
will always be 32-bit aligned. For instance, for a bitmap with a bitsBounds
having width 33 pixels, rowBytes
will be 8 to indicate 8 bytes offsets per horizontal line and 31 bits of unused data at the end of every horizontal line. view:LockScreen(nil)
message forces an "immediate update". How is this different from calling RefreshViews
?DrawShape
) the system normally renders the shape on the screen immediately. :LockScreen(true)
provides a way to "batch up" the screen updates for multiple drawing calls. Sending :LockScreen(nil)
"unplugs" the temporary block that has been placed on the screen updater, causing all the batched drawing changes to be rendered on the LCD.RefreshViews
tells the system to execute the commands needed to draw every view that has a dirty region. You can think of it as working at a level "above" the screen lock routines. When you send the message Dirty
, it does not immediately cause the system to redraw the dirtied view, instead it adds the view to the dirty area for later redrawing.SetValue
, call RefreshViews
(and not see an update) draw a few shapes, and then, when you unlock the screen, the refreshes to the dirty regions and your shapes will all appear at once.LockScreen
and RefreshViews
:LockScreen(nil)
result in a RefreshViews
?LockScreen(true)
just stops the hardware screen from updating from the offscreen buffer. LockScreen(nil)
releases that lock which usually causes the hardware screen to update soon thereafter.SetValues
draw into the offscreen buffer?SetValue
doesn't draw. Otherwise, see 1.RefreshViews
?vfFillWhite
and kRGB_0
but neither seems to work. How do I draw white text?textPattern
slot in the style frame to make the text black (kRGB_Black
) and set the transferMode
to modeBic
.kRGB_Gray1
for something that is as close to white as you can get.modeOr
- Replaces pixels under the non-white part of the source image with source pixels. If the source pixel is white, the destination pixel is unchanged.modeXor
- Inverts pixels under the non-white part of the source image. Destination pixels under the white part of the source image are unchanged. This actually XORs the values in the source and destination pixels. For example, for destination of 0xA (75% grey), source 0x0 (white) produces result 0xA (unchanged). Source 0xF (black), produces result 0x5 (25% grey, or inverted). Source pixels of other values have less utility. For example, source 0x5 (25% grey) produces result 0xF (black), while source 0xA (75% grey) produces result 0x0 (white), and source 0x3 (50% grey) produces result 0x9 (slightly less than 75% grey).modeBic
- Erases screen pixels under the non-white part of the source image, making them all white. Destination pixels under the white part of the source image are unchanged. This actually, does a bitwise NOT, so it is really only useful when source pixels are either 0 (white) or 0xF (black). With other values, weird things happen, For example, destination 0xF with source 0xA produces result 0x5. Destination 0x0 with source 0xA produces result 0x0. Destination 0x3 with source 0xA produces result 0x1. modeNotCopy
- Replaces screen pixels under the black part of the source image with white pixels. Screen pixels under the white part of the source image are made black.modeNotOr
- Screen pixels under the black part of the source image are unchanged. Screen pixels under the white part of the source image are made black.modeNotXor
- Screen pixels under the black part of the source image are unchanged. Screen pixels under the white part of the source image are inverted.GrayShrink
doing what I want it to when I use it with relatively small bitmaps?GrayShrink
was designed for rendering relatively large images such as received faxes into a moderately large part of a Newton display. It works by setting a flag in the bitmap that tells the imager to gather multiple bits from the source bitmap and turn them into a single gray pixel when drawing through a reducing transform. GrayShrink
will not modify the bitmap. The end result will be a transformed (shrunk) image with the same bit depth as the original. That is, the shrinking will still happen, but the graying won't.GrayShrink
will not work with read-only bitmaps (it is unable to set the flag.) The result will still be a transformed (shrunk) image, but pixels will not be combined to gray. There is no way to clear the flag once it has been set. After GrayShrink
has modified a bitmap, drawing it to the screen through any scaling transform that reduces the image will produce a pixel combined gray result.GrayShrink
pixel gathering algorithm produces an anomaly along the righthand side of the reduced image. When rendering large bitmaps into a reasonably large destination, this is generally uunnoticeable. However, when used with small source bitmaps or when rendering into a small area, several columns along the right side of the result may not be drawn, and the anomaly is easily seen. We recommend using GrayShrink
and the 'drawGrayScaled
setting for protoImageView
only for large source images such as incoming faxes or scanned data.MungeBitmap
to flip or rotate a grayscale image, it gets corrupted. What's wrong?MungeBitmap
does not properly handle bitmaps with a depth greater than 1. You can work around this problem by using kMungeBitmapFunc
, which has the same calling conventions and return value as MungeBitmap
. kMungeBitmapFunc
is provided in the Newton 2.1 Platform file, version 1.2b1 or later.MungeBitmap
with the 'rotateLeft
, 'rotateRight
, or 'flipHorizontal
options will trigger the bug. The 'rotate180
and 'flipVertical
arguments to MungeBitmap
work correctly with deeper bitmaps. TextBounds
and StrFontWidth
, but those values may be too small to fit.:LocalBox()
to find out) and use center justification in a style frame passed to :DrawShape(...)
.