[BUG] Problems with Stack Tutorial

Bob Arning arning at charm.net
Tue May 8 22:41:14 UTC 2001


Dan,

On Tue, 8 May 2001 15:04:58 -0700 (PDT) Dan Shafer <dshafer at yahoo.com> wrote:
>In 3.0 (3552), the project won't load completely. I get a dialog: "Reading an
>instance of FormStub. Which modern class should it translate to?" I haven't a
>clue.

Newer projects like "How to Make a Stack" require some stuff that is only found in 3.1.

>In 3.1 (3987), it loads fine and works up to the point of drawing on the card.
>At that point, it's not a problem with this project but with something in the
>latest round of changes, I suspect. Clicking the "Keep" button produces a
>walkback: "Bad BitBlt arg (Fraction?) proceed to convert." Clicking "Proceed"
>produces another walkback: "Error: A Primitive has failed." on the primitive
>CopyBits in BitBltPlugin.

Karl encountered this yesterday and Andreas posted this fix (it's in the internal updates and should be out before too long):


'From Squeak3.1alpha of 28 February 2001 [latest update: #3987] on 6 May 2001 at 4:29:18 pm'!
"Change Set:		CMFix-ar
Date:			6 May 2001
Author:			Andreas Raab

Fixes accidental generation of a color map where none was needed."!


!Form methodsFor: 'image manipulation' stamp: 'ar 5/6/2001 16:27'!
rectangleEnclosingPixelsNotOfColor: aColor
	"Answer the smallest rectangle enclosing all the pixels of me that are different from the given color. Useful for extracting a foreground graphic from its background."

	| cm slice copyBlt countBlt top bottom newH left right |
	"map the specified color to 1 and all others to 0"
	cm _ Bitmap new: (1 bitShift: (depth min: 15)).
	cm primFill: 1.
	cm at: (aColor indexInMap: cm) put: 0.

	"build a 1-pixel high horizontal slice and BitBlts for counting pixels of interest"
	slice _ Form extent: width at 1 depth: 1.
	copyBlt _ (BitBlt current toForm: slice)
		sourceForm: self;
		combinationRule: Form over;
		destX: 0 destY: 0 width: width height: 1;
		colorMap: cm.
	countBlt _ (BitBlt current toForm: slice)
		fillColor: (Bitmap with: 0);
		destRect: (0 at 0 extent: slice extent);
		combinationRule: 32.

	"scan in from top and bottom"
	top _ (0 to: height)
		detect: [:y |
			copyBlt sourceOrigin: 0 at y; copyBits.
			countBlt copyBits > 0]
		ifNone: [^ 0 at 0 extent: 0 at 0].
	bottom _ (height - 1 to: top by: -1)
		detect: [:y |
			copyBlt sourceOrigin: 0 at y; copyBits.
			countBlt copyBits > 0].

	"build a 1-pixel wide vertical slice and BitBlts for counting pixels of interest"
	newH _ bottom - top + 1.
	slice _ Form extent: 1 at newH depth: 1.
	copyBlt _ (BitBlt current toForm: slice)
		sourceForm: self;
		combinationRule: Form over;
		destX: 0 destY: 0 width: 1 height: newH;
		colorMap: cm.
	countBlt _ (BitBlt current toForm: slice)
		fillColor: (Bitmap with: 0);
		destRect: (0 at 0 extent: slice extent);
		combinationRule: 32.

	"scan in from left and right"
	left _ (0 to: width)
		detect: [:x |
			copyBlt sourceOrigin: x at top; copyBits.
			countBlt copyBits > 0].
	right _ (width - 1 to: left by: -1)
		detect: [:x |
			copyBlt sourceOrigin: x at top; copyBits.
			countBlt copyBits > 0].

	^ left at top corner: (right + 1)@(bottom + 1)
! !


Cheers,
Bob





More information about the Squeak-dev mailing list