|
It looks to me like it is the code that multiplies up the y direction. It seems to be giving values about 1/16 as large as they should be.
Good luck, brave programmer.
|
|
|
|
|
It was kind of. I was doing an add after a multiply instead of before it because I forgot some parens.
const size_t offs = ( (dstr.top()+dy)*dimensions().width+dstr.left() ) *pixel_type::bit_depth;
Real programmers use butterflies
|
|
|
|
|
It's the little things in life.
Jack of all trades, master of none, though often times better than master of one.
|
|
|
|
|
That describes much of programming perfectly!
|
|
|
|
|
Blowing a bit of smoke (pun?):
A few posters have shown discomfort with the idea of 2.25 bytes/pixel - I don't really understand their discomfort - the pixels are just there. Indeed, they are most easily grouped by the hardware/firmware in powers of two but that's only an artifact.
The problem, then, is that the artifact of basically all of our tools and abilities is geared towards powers of two and the data is not. Shyte, right ?
So, and here's the blowing smoke part - since you're going to commit a day of life to this (or so you threatened yourself). It's a matter of a proper set of masks - perched in an array that matches the pixel layout - but maybe the mask sizing should be larger than is usually intuitive. Find the lowest common multiple of 8 and 18 - and make that your mask size (at least to start) and then you simply (?) need to iterate through that array to isolate pixel (and/or their components).
You're much better at this than I, for sure, so the forgoing is an "out of the mouths of babes" type of suggestion.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Here's the thing. The # of channels per pixel, and the bit depth of each channel is arbitrary.
I could turn around right now and define a 19 bit pixel and the thing still needs to work.
So I have shifty bits in my code to ... shift bits. Also to set bits on non-byte boundaries.
static void shift_left(void* bits,size_t offset_bits,size_t size_bits, size_t shift) {
if(nullptr==bits || 0==size_bits || 0==shift) {
return;
}
if(shift>=size_bits) {
set_bits(bits,offset_bits,size_bits,false);
return;
}
uint8_t* pbegin = ((uint8_t*)bits)+(offset_bits/8);
const size_t offset = offset_bits % 8;
const size_t shift_bytes = shift / 8;
const size_t shift_bits = shift % 8;
const size_t overhang = (size_bits+offset_bits) % 8;
const uint8_t left_mask = ((uint8_t)uint8_t(0xFF<<(8-offset)));
const uint8_t right_mask = 0!=overhang?uint8_t(0xFF>>overhang):0;
uint8_t* pend = pbegin+(size_t)((offset_bits+size_bits)/8.0+.999999);
uint8_t* plast = pend-1;
uint8_t* psrc = pbegin+shift_bytes;
uint8_t* pdst = pbegin;
if(pbegin+1==pend) {
uint8_t save_mask = left_mask|right_mask;
uint8_t tmp = *pbegin;
*pbegin = uint8_t(uint8_t(tmp<<shift_bits)&~save_mask)|
uint8_t(tmp&save_mask);
return;
}
uint8_t left = *pbegin;
uint8_t right = *(pend-1);
while(pdst!=pend) {
uint8_t src = psrc<pend?*psrc:0;
uint8_t src2 = (psrc+1)<pend?*(psrc+1):0;
*pdst = (src<<shift_bits)|(src2>>(8-shift_bits));
++psrc;
++pdst;
}
*pbegin=(left&left_mask)|uint8_t(*pbegin&~left_mask);
--pend;
*plast=uint8_t(right&right_mask)|uint8_t(*plast&uint8_t(~right_mask));
};
I'll exclude shift_right, plus all the templatized versions of these functions that the compiler computes at compile time instead of run time
and
inline static void set_bits(size_t offset_bits,size_t size_bits,void* dst,const void* src) {
const size_t offset_bytes = offset_bits / 8;
const size_t offset = offset_bits % 8;
const size_t total_size_bytes = (offset_bits+size_bits)/8.0+.999999999;
const size_t overhang = (offset_bits+size_bits) % 8;
uint8_t* pbegin = ((uint8_t*)dst)+offset_bytes;
uint8_t* psbegin = ((uint8_t*)src)+offset_bytes;
uint8_t* pend = ((uint8_t*)dst)+total_size_bytes;
uint8_t* plast = pend-(pbegin!=pend);
const uint8_t maskL = 0!=offset?
(uint8_t)((uint8_t(0xFF>>offset))):
uint8_t(0xff);
const uint8_t maskR = 0!=overhang?
(uint8_t)~((uint8_t(0xFF>>overhang))):
uint8_t(0xFF);
if(pbegin==plast) {
uint8_t v = *psbegin;
const uint8_t mask = maskL & maskR;
v&=mask;
*pbegin&=~mask;
*pbegin|=v;
return;
}
*pbegin&=~maskL;
*pbegin|=((*psbegin)&maskL);
*plast&=~maskR;
*plast|=((*(psbegin+total_size_bytes-1))&maskR);
if(pbegin+1<plast) {
const size_t len = plast-(pbegin+1);
if(0!=len&&len<=total_size_bytes)
memcpy(pbegin+1,psbegin+1,len);
}
}
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: I needed a pair of parentheses. WELL, WELL, WELL!!!
If only someone had warned you about your poor usage of parenthesis!
|
|
|
|
|
Message Closed
modified 12-Apr-21 9:21am.
|
|
|
|
|
Please clarify. Are you interested in learning about general software development, or specifically in designing a new software language?
|
|
|
|
|
No need for clarification; his post is only there for the hidden spam link.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I can't find one, even when mousing around. What's your secret?
EDIT: Never mind. Found it.
modified 12-Apr-21 9:28am.
|
|
|
|
|
|
It will soon be time to say adios.
|
|
|
|
|
Don't forget to report the message you've just replied to, which also contains a hidden link.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
As it says...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
You learn to develop languages by trying many languages.
|
|
|
|
|
It's a hidden link spammer.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks. Removed the link.
|
|
|
|
|
PIEBALDconsult wrote: Removed the link. and the evidence that he's a spammer.
|
|
|
|
|
You want a "positive response"? I am positive that your hidden-link spam is not going to last long.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
It's still only got 2 kicks - and one of 'em was mine!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
You can really learn some language if you listen to 'rap music' of spend some time in a bar full of drunken sailors. Or drunken anyone, for that matter.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Except she can't - Covid regulations, you know.
So spamming - fairly badly - is all she can do, poor thing.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: So spamming - fairly badly - is all she can do, poor thin Yeah - quite true. One would be hard put to find a worse place to spam the a developer's site.
It's a good thing we don't have (a publicly acknowledged) death squad to met out punishment.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
There are no real tutorials for languages (C#, C++... ) on CodeProject (unfortunately).
You should get a book (paper or online) or look at places like udemy.com for beginner language tutorials.
I've seen (in an email/twitter) that CodeProject is starting a mentor programs; but I've not looked into it.
I'd rather be phishing!
|
|
|
|