Click here to Skip to main content
15,927,347 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Error Reading Raw Pixel Data Into Bitmap Pin
Sonhospa17-May-10 5:09
Sonhospa17-May-10 5:09 
AnswerRe: Error Reading Raw Pixel Data Into Bitmap Pin
DaveAuld17-May-10 1:52
professionalDaveAuld17-May-10 1:52 
GeneralRe: Error Reading Raw Pixel Data Into Bitmap Pin
Sonhospa17-May-10 5:26
Sonhospa17-May-10 5:26 
AnswerRe: Error Reading Raw Pixel Data Into Bitmap Pin
Luc Pattyn17-May-10 3:41
sitebuilderLuc Pattyn17-May-10 3:41 
GeneralRe: Error Reading Raw Pixel Data Into Bitmap Pin
Sonhospa17-May-10 5:41
Sonhospa17-May-10 5:41 
GeneralRe: Error Reading Raw Pixel Data Into Bitmap Pin
Luc Pattyn17-May-10 5:47
sitebuilderLuc Pattyn17-May-10 5:47 
AnswerResolved: Scaling Raw Pixel Data When Reading Into Bitmap Pin
Sonhospa17-May-10 10:59
Sonhospa17-May-10 10:59 
GeneralRe: Resolved: Scaling Raw Pixel Data When Reading Into Bitmap Pin
Luc Pattyn17-May-10 11:44
sitebuilderLuc Pattyn17-May-10 11:44 
Hi Michael,

yes that looks like a valid attempt, or at least pretty close to it.

I'm a bit worried about you having three stride variables; and I'm not convinced the heavy writePosition calculation is warranted (aren't you generating all the result pixels simply in their logical order anyway?).

Here are some more ideas:

1.
your subsampling assumes an integer scale; you could also apply fractional sampling, which basically means when you want row Z with a scalefactor of T/N, you calculate Zscaled=Z*T/N, which, rounded to some integer value, tells you which row to use. Similar for horizontal scaling.
If you want to do the fast scan direction efficiently, you may want to study the Bresenham algorithm.

2.
Rather than skipping pixels one by one, as your final for loop does, I would consider this:
- read an entire row at a time, asking the stream to fill an uint array with the correct number of bytes;
- use a pointer inside the uint array to access pixels or colorcomponents.
The net result is the last for loop becomes a simple addition.

3.
Assuming you want maximum performance, I would also consider:
- smashing the byte swap logic, i.e. copying the SwapDWORD code into your current snippet (manual inlining);
- removing all multiplications from the loops; either do them once, beforehand; or use a running sum, as appropriate.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read formatted code with indentation, so please use PRE tags for code snippets.

I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).

QuestionRun-time error Pin
MsmVc16-May-10 19:24
MsmVc16-May-10 19:24 
AnswerRe: Run-time error Pin
Richard MacCutchan16-May-10 21:13
mveRichard MacCutchan16-May-10 21:13 
GeneralRe: Run-time error Pin
MsmVc16-May-10 21:34
MsmVc16-May-10 21:34 
GeneralRe: Run-time error Pin
DaveAuld16-May-10 23:01
professionalDaveAuld16-May-10 23:01 
GeneralRe: Run-time error Pin
MsmVc16-May-10 23:06
MsmVc16-May-10 23:06 
GeneralRe: Run-time error Pin
DaveAuld16-May-10 23:55
professionalDaveAuld16-May-10 23:55 
GeneralRe: Run-time error Pin
MsmVc16-May-10 23:57
MsmVc16-May-10 23:57 
GeneralRe: Run-time error Pin
DaveAuld16-May-10 23:59
professionalDaveAuld16-May-10 23:59 
GeneralRe: Run-time error Pin
MsmVc17-May-10 0:10
MsmVc17-May-10 0:10 
GeneralRe: Run-time error [modified] Pin
DaveAuld17-May-10 0:43
professionalDaveAuld17-May-10 0:43 
GeneralRe: Run-time error Pin
MsmVc18-May-10 22:15
MsmVc18-May-10 22:15 
GeneralRe: Run-time error Pin
DaveAuld18-May-10 22:54
professionalDaveAuld18-May-10 22:54 
AnswerRe: Run-time error Pin
Sonhospa16-May-10 23:57
Sonhospa16-May-10 23:57 
AnswerRe: Run-time error Pin
William Winner17-May-10 8:10
William Winner17-May-10 8:10 
GeneralRe: Run-time error Pin
DaveAuld18-May-10 22:54
professionalDaveAuld18-May-10 22:54 
GeneralRe: Run-time error Pin
William Winner19-May-10 4:45
William Winner19-May-10 4:45 
GeneralRe: Run-time error Pin
DaveAuld19-May-10 4:48
professionalDaveAuld19-May-10 4:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.