From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7af3eb61e15f9a0b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-17 10:20:29 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!ppp-1-119.cvx2.telinco.NET!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: pointer movement? Date: Sat, 17 Nov 2001 17:54:55 -0000 Message-ID: <9t69pa$jh6l$1@ID-25716.news.dfncis.de> References: <9t5ihf$dp$1@news.tpi.pl> NNTP-Posting-Host: ppp-1-119.cvx2.telinco.net (212.1.140.119) X-Trace: fu-berlin.de 1006021227 640213 212.1.140.119 (16 [25716]) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Xref: archiver1.google.com comp.lang.ada:16645 Date: 2001-11-17T17:54:55+00:00 List-Id: To my mind, it would be preferable if you did this at a higher level. E.g.: type Channel_Value is delta 1.0/256 range 0.0 .. 2.0; subtype Stored_Value is Channel_Value range 0.0 .. 1.0; --? for Stored_Value'Size use 8; type Channel_Selector is (Red, Green, Blue, Alpha); --? for Channel_Selector'Size use 4; subtype Colour_Channel is Channel_Selector range Red..Blue; type RGBA is array (Channel_Selector) of Stored_Value; --? pragma Pack(RGBA); --? for RGBA'Size use 4*Stored_Value'Size; type Screenful is array (0..639,0..359) of RGBA; --? pragma Pack(Screenful); --? for Screenful'Size use 640*360*RGBA'Size; S1, S2: Screenful; ... for x in Screenful'Range(1) loop for y in Screenful'Range(2) loop if S2(x,y)(Alpha) /= 0.0 then if S1(x,y)(Alpha) = 0.0 then S1(x,y) := S2(x,y); else for C in Colour_Channel loop S1(x,y)(C) := (S1(x,y)(C)*S1(x,y)(Alpha) + S2(x,y)(C)*S2(x,y)(Alpha))/(S1(x,y)(Alpha)+S2(x,y)(Alpha)); S1(x,y)(Alpha) := (S1(x,y)(Alpha)+S2(x,y)(Alpha))/2; end loop; end if; end if; end loop; end loop; Note how representation clauses can be used (up to a point) to make Ada's representations match those of the hardware. Whether you get adequate speed is largely up to the optimisations provided by the compiler (remember to turn on all the right switches). Of course, you could help by removing loop invariants etc. (but the compiler ought to do these for you, really). If this is not fast enough, you might consider going to assembly (especially if that means you can take advantage of MMX or SIMD or whatever). Most modern graphics cards provide a variety of functions onboard. You can sometimes get a major overall speed boost by offloading work to the graphics co-processor (freeing up the main processor for other things). Sometimes, in fact, it's much faster to have the main processor do it (because it's so much faster than the graphics co-processor). Hope this is helpful in some way. -- Best wishes, Nick Roberts "Andrzej Rybczynski" wrote in message news:9t5ihf$dp$1@news.tpi.pl... > I want to do some transformations of large bitmap (dynamically > allocated). With c/c++ I used to do this by moving pointer from > pixel to pixel over all array. What is most important - it has to be > extremely fast. How should I do this in Ada? Can I use package > System.Storage_Elements for this purpose ?