archive-com.com » COM » E » EFG2.COM

Total: 878

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • efg's Color Split Lab Report
    to start the program Press the Read BMP button and select a 24 bit color image to split Select how to display the image RGB Composite or RGB Plane or HSV Plane Press the Monochrome checkbox to display a color image in shades of gray Discussion The ImageLib unit has a RGBtoHSV function to convert from RGB coordinates to HSV coordinates To avoid having to deal with palettes the gray

    Original URL path: http://www.efg2.com/Lab/Graphics/Colors/Split.htm (2016-02-14)
    Open archived version from archive



  • a given output row y the input row is factor y for the normal case and height 1 factor y for the flipped case Stacking the IF THEN ELSE statement like shown below may be unconventional but shows the logic much more clearly IMHO Likewise for a given output column x the needed input column is factor x for the normal case and width 1 factor x for the reversed case I hope you can figure this out If not feel free to ask any followup questions unit Unit1 interface uses Windows Messages SysUtils Classes Graphics Controls Forms Dialogs StdCtrls ExtCtrls type TForm1 class TForm Button1 TButton CheckBoxFlip TCheckBox Image1 TImage EditFilename TEdit EditFactor TEdit CheckBoxReverse TCheckBox LabelShrinkFactor TLabel procedure Button1Click Sender TObject private Private declarations public Public declarations end var Form1 TForm1 implementation R DFM Flip Reverse Shrink bitmap Shrink by resampling by specified factor in both dimensions FUNCTION FlipReverse CONST FName STRING CONST FlipIt BOOLEAN CONST ReverseIt BOOLEAN CONST Factor INTEGER TBitmap TYPE TRGBTripleArray ARRAY WORD OF TRGBTriple pRGBTripleArray TRGBTripleArray VAR Bitmap TBitmap ColumnIn INTEGER rowIn pRGBTripleArray RowOut pRGBTripleArray x INTEGER y INTEGER BEGIN ASSERT Factor 0 BitMap TBitMap Create Result TBitMap Create try BitMap LoadfromFile FName TRGBTripleArray Scanline is only good for pf24bit bitmap so force this if necessary IF Bitmap PixelFormat pf24bit THEN Bitmap PixelFormat pf24bit Output bitmap is same size as Input only if Factor 1 Result Height BitMap Height DIV Factor Result Width BitMap Width DIV Factor Result PixelFormat BitMap PixelFormat pf24bit Only process output pixels and fetch pixels from input bitmap Define flip to be top to bottom and reverse to be left to right for y 0 TO BitMap Height DIV Factor 1 do begin rowOut Result Scanline y if FlipIt then rowIn Bitmap Scanline Bitmap Height 1 Factor y else rowIn

    Original URL path: http://www.efg2.com/Lab/Library/Delphi/Graphics/ShrinkFlipReverse.txt (2016-02-14)
    Open archived version from archive


  • that are different PROCEDURE CompareBitmaps CONST BitmapA BitmapB TBitmap VAR Total Match Differ INTEGER TYPE TRGBTripleArray ARRAY WORD OF TRGBTriple pRGBTripleArray TRGBTripleArray VAR i INTEGER j INTEGER rowA pRGBTripleArray rowB pRGBTripleArray BEGIN ASSERT BitmapA width BitmapB width AND BitmapA height BitmapB height Different sizes Force bitmaps to have the same pf24bit Pixelformat this may be undesirable for example for large pf1bit bitmaps BitmapA PixelFormat pf24bit BitmapB PixelFormat pf24bit Total BitmapA width BitmapA height Match 0 Differ 0 FOR j 0 TO BitmapA height 1 DO BEGIN rowA BitmapA Scanline j rowB BitmapB Scanline j FOR i 0 TO BitmapA width 1 DO BEGIN IFDEF DELPHI5 DEFINE SIMPLEWAY ENDIF IFDEF DELPHI6 should work in D6 DEFINE SIMPLEWAY ENDIF IFDEF SIMPLEWAY update this for D7 or later new easy way for D5 or later actually D4 02 and later IF rowA i rowB i THEN INC Match ELSE INC Differ ELSE D3 and D4 cannot use simple way bug in earlier versions forces more code for test IF rowA i rgbtRed rowB i rgbtRed AND rowA i rgbtGreen rowB i rgbtGreen AND rowA i rgbtBlue rowB i rgbtBlue THEN INC Match ELSE INC Differ ENDIF END END END CompareBitmaps procedure TForm1 ButtonCompareClick

    Original URL path: http://www.efg2.com/Lab/Library/Delphi/Graphics/CompareTBitmaps.TXT (2016-02-14)
    Open archived version from archive


  • your routine if the bitmap is not a genuine 24 bit bitmap I did some tests with a 889 x 932 bitmap execution times in msec 366 MHz Celeron RGB averaging code 37 pixel format conversion pf4bit 67 pf8bit 63 pf16bit 94 pf24bit no conv 0 01 pf32bit 84 it is possible to speed up the averaging code a bit using assembler The following code needs about 23 msec instead of 37 to scan the 889 x 932 bitmap mentioned above var X Y W Integer P PRGBTriple r g b Pixels Integer averagecolor TColor Bmp TBitmap begin r 0 g 0 b 0 W Width for y 0 to Height 1 do begin P ScanLine y asm mov ecx W and ecx ecx jz end push ebx push esi push edi mov edi ecx mov ebx b mov ecx g mov edx r mov esi P Next movzx eax BYTE PTR esi add ebx eax movzx eax BYTE PTR esi 1 add ecx eax movzx eax BYTE PTR esi 2 add edx eax dec edi jz finis movzx eax BYTE PTR esi 3 add ebx eax movzx eax BYTE PTR esi 4 add ecx eax movzx eax BYTE PTR

    Original URL path: http://www.efg2.com/Lab/Library/UseNet/2000/0202.txt (2016-02-14)
    Open archived version from archive


  • Bitmap1 Canvas Brush Color clYellow Bitmap1 Canvas FillRect Bitmap1 Canvas ClipRect Keep Bitmap1 as an untouched orignal Bitmap2 should be a deep copy of Bitmap1 not just a pointer to it Bitmap2 TBitmap Create TRY Bitmap2 Assign Bitmap1 Kludge to force independent copy in D3 and D4 IF CheckBoxKludge Checked THEN Bitmap2 Canvas Pixels 0 0 Bitmap2 Canvas Pixels 0 0 Change Bitmap2 don t do anything to Bitmap1 FOR

    Original URL path: http://www.efg2.com/Lab/ImageProcessing/ScreenBitmapAssignEnigma.pas.TXT (2016-02-14)
    Open archived version from archive


  • Scanline Enigma Bug or something simple Author ullrich Email ullrich math okstate edu Date 1998 10 15 Well it looks fairly enigmatic to me too yes I get the same AV The fact that Method B works seems to rule out the idea that it s some obscure assignment compatibility thing Oh the AV goes away if I turn off optimization So it s a bug David C Ullrich Re Scanline Enigma Bug or something simple more options Author Earl F Glynn Thanks MUCH David Your suggestion worked fine So my new question is No Optimization or Kludge That I Can Live With I don t think I ve ever turned off optimization I was surprised to learn that you can only turn optimization on or off for the whole module I tried to turn it off for the one statement or the nested loops but that didn t work See Stefan Hoffmeister s post below optimization is on a per method function basis So I ran a short timing test copying a 640 by 480 pf24bit bitmap like in the original post I did this for Methods A B C D and E both With and Without Compiler Optimization Here are the results mean s d for a 166 MHz Pentium With and Without Compiler Optimization Method A With 151 7 ms Without 380 50 Method B With 104 7 ms Without 163 12 Method C With 193 22ms Without 260 28 Method D With Access Violation Without 137 1 Method E With 140 28 Without 244 129 This would have looked better in an HTML table but I didn t want to risk the wrath of those that don t like HTML in posts So Method B With Optimization seems the way to go In summary VAR rowInB pRGBTripleArray rowInA pRGBTripleArray i INTEGER AvoidOptimizationBug TRGBTriple Optimization Bug RowInB i RowInA i AvoidOptimizationBug RowInA i Kludge workaround RowInB i AvoidOptimizationBug I ve worked around this bug for months but yesterday I decided I had to figure out why it happened occasionally Maybe in Delphi 5 Method D will work with optimization THANKS AGAIN Dave efg Re Scanline Enigma Bug or something simple more options Author Stefan Hoffmeister Date 1998 10 15 I don t think I ve ever turned off optimization I was surprised to learn that you can only turn optimization on or off for the whole module I tried to turn it off for the one statement or the nested loops but that didn t work FYI it works on a per method function basis No need to twiddle with the whole module Stefan Hoffmeister http www econos de Re Scanline Enigma Bug or something simple Author Tim Roberts Date 1998 10 15 Earl F Glynn wrote Am I missing something simple here Nope I don t think so Method D Why does this fail with an access violation In debugger RowInA is 8352B880 and RowInB is 83657880 i 0 Why does access violation occur at 0042DABF

    Original URL path: http://www.efg2.com/Lab/Library/Delphi/Graphics/ScanlineEnigma.TXT (2016-02-14)
    Open archived version from archive


  • machine This code fragment doesn t do anything useful at execution time Create a new project and put the code below in the Button1Click event and just see if the project will compile successfully unit ScreenFixLogo interface uses Windows Messages SysUtils Classes Graphics Controls Forms Dialogs ExtCtrls StdCtrls type TForm1 class TForm Button1 TButton procedure Button1Click Sender TObject private Private declarations public Public declarations end var Form1 TForm1 implementation R DFM procedure TForm1 Button1Click Sender TObject TYPE TRGBTripleArray ARRAY WORD OF TRGBTriple pRGBTripleArray TRGBTripleArray VAR BitmapIn TBitmap BitmapOut TBitmap i j INTEGER RowIn pRGBTripleArray RowOut pRGBTripleArray begin BitmapIn TBitmap Create TRY BitmapIn LoadFromFile global logo bmp BitmapOut TBitmap Create TRY BitmapOut Width BitmapIn Width BitmapOut Height BitmapIn Height BitmapOut PixelFormat pf24bit FOR j 0 TO BitmapIn Height 1 DO BEGIN RowIn BitmapIn Scanline j RowOut BitmapOut Scanline j FOR i 0 TO BitmapIn Width 1 DO BEGIN CASE RowIn i rgbtRed OF 0 BEGIN RowOut i rgbtRed 255 RowOut i rgbtGreen 255 RowOut i rgbtBlue 255 END 255 RowOut i RowIn i ELSE RowOut i rgbtRed 0 RowOut i rgbtGreen 0 RowOut i rgbtBlue 0 END END END FINALLY BItmapOut Free END FINALLY BitmapIn Free END end end What s

    Original URL path: http://www.efg2.com/Lab/Library/UseNet/2000/0222b.txt (2016-02-14)
    Open archived version from archive


  • working OK some of the time However sometimes it seems to slow down by about 1000 times The bit that is taking the time I think is accessing a TBitmap by scanline It seems from stepping through the VCL code that every time I access the scanline the bitmap is getting deleted and recreated I m not totally sure because I don t really follow the VCL code Maybe you

    Original URL path: http://www.efg2.com/Lab/Library/UseNet/2002/0306.txt (2016-02-14)
    Open archived version from archive



  •